Path: blob/jdk8u272-b10-aarch32-20201026/jdk/test/java/net/Inet6Address/serialize/Inet6AddressSerializationTest.java
48795 views
/*1* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223import java.io.ByteArrayInputStream;24import java.io.ByteArrayOutputStream;25import java.io.FileNotFoundException;26import java.io.FileOutputStream;27import java.io.IOException;28import java.io.ObjectInputStream;29import java.io.ObjectOutputStream;30import java.io.PrintStream;31import java.net.Inet6Address;32import java.net.InetAddress;33import java.net.NetworkInterface;34import java.net.UnknownHostException;35import java.util.ArrayList;36import java.util.Arrays;37import java.util.Enumeration;38import java.util.List;3940/**41* @test42* @bug 800737343* @summary jdk7 backward compatibility serialization problem44*/4546public class Inet6AddressSerializationTest {4748static boolean failed;4950public static final int LOOPBACK_SCOPE_ID = 0;5152public static final byte[] IN6ADDR_ANY_INIT = { (byte) 0x00, (byte) 0x00,53(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,54(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,55(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 };5657public static final byte[] LOOPBACKIPV6ADDRESS = { (byte) 0x00,58(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,59(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,60(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01 };6162// fe80::21b:24ff:febd:f29c63public static final byte[] E1000G0IPV6ADDRESS = { (byte) 0xfe, (byte) 0x80,64(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,65(byte) 0x00, (byte) 0x02, (byte) 0x1b, (byte) 0x24, (byte) 0xff,66(byte) 0xfe, (byte) 0xbd, (byte) 0xf2, (byte) 0x9c };6768public static final String E1000G0HOSTNAME = "fe80:0:0:0:21b:24ff:febd:f29c%e1000g0";6970public static final String LOCALHOSTNAME = "localhost";7172public static final String NETWORK_IF_E1000G0 = "e1000g0";7374public static final String NETWORK_IF_LO0 = "lo0";7576public static final int SCOPE_ID_E1000G0 = 2;7778public static final int SCOPE_ID_LO0 = 1;7980public static final int SCOPE_ID_ZERO = 0;8182public static void main(String[] args) throws Exception {83// args[0] == generate-loopback generates serial data for loopback if84// args[0] == generateAll generates serial data for interfaces with an85// IPV6 address binding8687if (args.length != 0) {8889if (args[0].equals("generate-loopback")) {9091generateSerializedInet6AddressData(Inet6Address.getByAddress(92InetAddress.getLoopbackAddress().getHostName(),93LOOPBACKIPV6ADDRESS, LOOPBACK_SCOPE_ID), System.out,94true);9596} else {97generateAllInet6AddressSerializedData();98}99} else {100runTests();101}102}103104private static void runTests() throws UnknownHostException, Exception,105IOException {106byte[] thisHostIPV6Address = null;107int scope_id = LOOPBACK_SCOPE_ID;108109System.out.println("Hostname: "110+ InetAddress.getLocalHost().getHostName());111System.out.println("LocalHost isLoopback : "112+ InetAddress.getLocalHost().isLoopbackAddress());113thisHostIPV6Address = getThisHostIPV6Address(InetAddress.getLocalHost()114.getHostName());115116if (thisHostIPV6Address == null) {117thisHostIPV6Address = IN6ADDR_ANY_INIT;118}119120// testing JDK7 generated serialized loopback against locally generated121// loopback address122testInet6AddressSerialization(Inet6Address.getByAddress(InetAddress123.getLoopbackAddress().getHostName(), LOOPBACKIPV6ADDRESS,124scope_id), JDK7Inet6AddressSerialData);125// testing JDK8 generated serialized loopback against locally generated126// loopback address127testInet6AddressSerialization(Inet6Address.getByAddress(InetAddress128.getLoopbackAddress().getHostName(), LOOPBACKIPV6ADDRESS,129scope_id), JDK8Inet6AddressSerialData);130testInet6AddressSerialization(Inet6Address.getByAddress(InetAddress131.getLocalHost().getHostName(), IN6ADDR_ANY_INIT, scope_id),132null);133testInet6AddressSerialization(Inet6Address.getByAddress(InetAddress134.getLocalHost().getHostName(), thisHostIPV6Address, scope_id),135null);136testAllNetworkInterfaces();137138// test against lo0139testSerializedLo0Inet6Address();140141testSerializedE1000gInet6Address();142143if (failed)144throw new RuntimeException("Some tests failed, check output");145}146147private static byte[] getThisHostIPV6Address(String hostName)148throws Exception {149InetAddress[] thisHostIPAddresses = null;150try {151thisHostIPAddresses = InetAddress.getAllByName(InetAddress152.getLocalHost().getHostName());153} catch (UnknownHostException uhEx) {154uhEx.printStackTrace();155throw uhEx;156}157byte[] thisHostIPV6Address = null;158for (InetAddress inetAddress : thisHostIPAddresses) {159if (inetAddress instanceof Inet6Address) {160if (inetAddress.getHostName().equals(hostName)) {161thisHostIPV6Address = inetAddress.getAddress();162break;163}164}165}166// System.err.println("getThisHostIPV6Address: address is "167// + Arrays.toString(thisHostIPV6Address));168return thisHostIPV6Address;169}170171static void testAllNetworkInterfaces() throws Exception {172System.err.println("\n testAllNetworkInterfaces: \n ");173for (Enumeration<NetworkInterface> e = NetworkInterface174.getNetworkInterfaces(); e.hasMoreElements();) {175NetworkInterface netIF = e.nextElement();176for (Enumeration<InetAddress> iadrs = netIF.getInetAddresses(); iadrs177.hasMoreElements();) {178InetAddress iadr = iadrs.nextElement();179if (iadr instanceof Inet6Address) {180System.err.println("Test NetworkInterface: " + netIF);181Inet6Address i6adr = (Inet6Address) iadr;182System.err.println("Testing with " + iadr);183System.err.println(" scoped iface: "184+ i6adr.getScopedInterface());185testInet6AddressSerialization(i6adr, null);186}187}188}189}190191static void displayExpectedInet6Address(Inet6Address expectedInet6Address) {192193String expectedHostName = expectedInet6Address.getHostName();194byte[] expectedAddress = expectedInet6Address.getAddress();195String expectedHostAddress = expectedInet6Address.getHostAddress();196int expectedScopeId = expectedInet6Address.getScopeId();197NetworkInterface expectedNetIf = expectedInet6Address198.getScopedInterface();199200System.err.println("Excpected HostName: " + expectedHostName);201System.err.println("Expected Address: "202+ Arrays.toString(expectedAddress));203System.err.println("Expected HostAddress: " + expectedHostAddress);204System.err.println("Expected Scope Id " + expectedScopeId);205System.err.println("Expected NetworkInterface " + expectedNetIf);206System.err.println("Expected Inet6Address " + expectedInet6Address);207}208209// test serialization deserialization of Inet6Address210static void testInet6AddressSerialization(211Inet6Address expectedInet6Address, byte[] serializedAddress)212throws IOException {213System.err.println("\n testInet6AddressSerialization: enter \n");214215// displayExpectedInet6Address(expectedInet6Address);216217byte[] serialData = serializedAddress != null ? serializedAddress218: generateSerializedInet6AddressData(expectedInet6Address,219null, false);220try (ByteArrayInputStream bis = new ByteArrayInputStream(serialData);221ObjectInputStream oin = new ObjectInputStream(bis)) {222Inet6Address deserializedIPV6Addr = (Inet6Address) oin.readObject();223System.err.println("Deserialized Inet6Address "224+ deserializedIPV6Addr);225assertHostNameEqual(expectedInet6Address.getHostName(),226deserializedIPV6Addr.getHostName());227assertHostAddressEqual(expectedInet6Address.getHostAddress(),228deserializedIPV6Addr.getHostAddress());229assertAddressEqual(expectedInet6Address.getAddress(),230deserializedIPV6Addr.getAddress());231assertScopeIdEqual(expectedInet6Address.getScopeId(),232deserializedIPV6Addr.getScopeId());233assertNetworkInterfaceEqual(234expectedInet6Address.getScopedInterface(),235deserializedIPV6Addr.getScopedInterface());236} catch (Exception e) {237System.err.println("Exception caught during deserialization");238failed = true;239e.printStackTrace();240}241}242243static void testSerializedE1000gInet6Address() throws IOException {244System.err.println("\n testSerializedE1000gInet6Address: enter \n");245boolean testWithNetIf = true;246boolean useMockInet6Address = false;247248NetworkInterface testNetIf = NetworkInterface249.getByName(NETWORK_IF_E1000G0);250Inet6Address expectedInet6Address = null;251if (testNetIf != null) {252System.err253.println("\n testSerializedE1000gInet6Address: using netif \n");254try {255expectedInet6Address = Inet6Address.getByAddress(256E1000G0HOSTNAME, E1000G0IPV6ADDRESS, testNetIf);257} catch (UnknownHostException ukhEx) {258ukhEx.printStackTrace();259testWithNetIf = true;260useMockInet6Address = true;261}262} else {263System.err264.println("\n testSerializedE1000gInet6Address: using index \n");265try {266expectedInet6Address = Inet6Address.getByAddress(267E1000G0HOSTNAME, E1000G0IPV6ADDRESS, SCOPE_ID_ZERO);268} catch (UnknownHostException ukhEx1) {269ukhEx1.printStackTrace();270useMockInet6Address = true;271}272testWithNetIf = false;273}274275byte[] serializedAddress = SerialData_ifname_e1000g0;276277// displayExpectedInet6Address(expectedInet6Address);278279try (ByteArrayInputStream bis = new ByteArrayInputStream(280serializedAddress);281ObjectInputStream oin = new ObjectInputStream(bis)) {282Inet6Address deserializedIPV6Addr = (Inet6Address) oin.readObject();283System.err.println("Deserialized Inet6Address "284+ deserializedIPV6Addr);285286if (!useMockInet6Address) {287assertHostNameEqual(expectedInet6Address.getHostName(),288deserializedIPV6Addr.getHostName());289if (testWithNetIf) {290assertHostAddressEqual(291expectedInet6Address.getHostAddress(),292deserializedIPV6Addr.getHostAddress());293} else {294assertHostAddressEqual(295MockE1000g0Inet6Address.getBareHostAddress(),296deserializedIPV6Addr.getHostAddress());297}298assertAddressEqual(expectedInet6Address.getAddress(),299deserializedIPV6Addr.getAddress());300assertScopeIdEqual(expectedInet6Address.getScopeId(),301deserializedIPV6Addr.getScopeId());302if (testWithNetIf) {303assertNetworkInterfaceEqual(304expectedInet6Address.getScopedInterface(),305deserializedIPV6Addr.getScopedInterface());306} else {307assertNetworkInterfaceEqual(null,308deserializedIPV6Addr.getScopedInterface());309}310} else { // use MockLo0Inet6Address311assertHostNameEqual(MockE1000g0Inet6Address.getHostName(),312deserializedIPV6Addr.getHostName());313if (testWithNetIf) {314assertHostAddressEqual(315MockE1000g0Inet6Address.getHostAddress(),316deserializedIPV6Addr.getHostAddress());317} else {318assertHostAddressEqual(319MockE1000g0Inet6Address.getHostAddressWithIndex(),320deserializedIPV6Addr.getHostAddress());321}322assertAddressEqual(MockE1000g0Inet6Address.getAddress(),323deserializedIPV6Addr.getAddress());324if (testWithNetIf) {325assertScopeIdEqual(MockE1000g0Inet6Address.getScopeId(),326deserializedIPV6Addr.getScopeId());327} else {328assertScopeIdEqual(MockE1000g0Inet6Address.getScopeZero(),329deserializedIPV6Addr.getScopeId());330}331assertNetworkInterfaceNameEqual(332MockE1000g0Inet6Address.getScopeIfName(),333deserializedIPV6Addr.getScopedInterface());334}335} catch (Exception e) {336System.err.println("Exception caught during deserialization");337failed = true;338e.printStackTrace();339}340}341342static void testSerializedLo0Inet6Address() throws IOException {343System.err.println("\n testSerializedLo0Inet6Address: enter \n");344boolean testWithNetIf = true;345boolean useMockInet6Address = false;346347NetworkInterface testNetIf = NetworkInterface.getByName(NETWORK_IF_LO0);348Inet6Address expectedInet6Address = null;349if (testNetIf != null) {350System.err351.println("\n testSerializedLo0Inet6Address: using netif \n");352try {353expectedInet6Address = Inet6Address.getByAddress(LOCALHOSTNAME,354LOOPBACKIPV6ADDRESS, testNetIf);355} catch (UnknownHostException ukhEx) {356ukhEx.printStackTrace();357testWithNetIf = true;358useMockInet6Address = true;359}360} else {361System.err362.println("\n testSerializedLo0Inet6Address: using index \n");363try {364expectedInet6Address = Inet6Address.getByAddress(LOCALHOSTNAME,365LOOPBACKIPV6ADDRESS, SCOPE_ID_ZERO);366} catch (UnknownHostException ukhEx1) {367ukhEx1.printStackTrace();368useMockInet6Address = true;369}370testWithNetIf = false;371}372373// displayExpectedInet6Address(expectedInet6Address);374375byte[] serializedAddress = SerialData_ifname_lo0;376377try (ByteArrayInputStream bis = new ByteArrayInputStream(378serializedAddress);379ObjectInputStream oin = new ObjectInputStream(bis)) {380Inet6Address deserializedIPV6Addr = (Inet6Address) oin.readObject();381System.err.println("Deserialized Inet6Address "382+ deserializedIPV6Addr);383if (!useMockInet6Address) {384assertHostNameEqual(expectedInet6Address.getHostName(),385deserializedIPV6Addr.getHostName());386if (testWithNetIf) {387assertHostAddressEqual(388expectedInet6Address.getHostAddress(),389deserializedIPV6Addr.getHostAddress());390} else {391assertHostAddressEqual(392MockLo0Inet6Address.getBareHostAddress(),393deserializedIPV6Addr.getHostAddress());394}395assertAddressEqual(expectedInet6Address.getAddress(),396deserializedIPV6Addr.getAddress());397assertScopeIdEqual(expectedInet6Address.getScopeId(),398deserializedIPV6Addr.getScopeId());399if (testWithNetIf) {400assertNetworkInterfaceEqual(401expectedInet6Address.getScopedInterface(),402deserializedIPV6Addr.getScopedInterface());403} else {404assertNetworkInterfaceEqual(null,405deserializedIPV6Addr.getScopedInterface());406}407} else { // use MockLo0Inet6Address408assertHostNameEqual(MockLo0Inet6Address.getHostName(),409deserializedIPV6Addr.getHostName());410if (testWithNetIf) {411assertHostAddressEqual(412MockLo0Inet6Address.getHostAddress(),413deserializedIPV6Addr.getHostAddress());414} else {415assertHostAddressEqual(416MockLo0Inet6Address.getHostAddressWithIndex(),417deserializedIPV6Addr.getHostAddress());418}419assertAddressEqual(MockLo0Inet6Address.getAddress(),420deserializedIPV6Addr.getAddress());421if (testWithNetIf) {422assertScopeIdEqual(MockLo0Inet6Address.getScopeId(),423deserializedIPV6Addr.getScopeId());424} else {425assertScopeIdEqual(MockLo0Inet6Address.getScopeZero(),426deserializedIPV6Addr.getScopeId());427}428assertNetworkInterfaceNameEqual(429MockLo0Inet6Address.getScopeIfName(),430deserializedIPV6Addr.getScopedInterface());431}432} catch (Exception e) {433System.err.println("Exception caught during deserialization");434failed = true;435e.printStackTrace();436}437}438439static List<Inet6Address> getAllInet6Addresses() throws Exception {440// System.err.println("\n getAllInet6Addresses: \n ");441ArrayList<Inet6Address> inet6Addresses = new ArrayList<Inet6Address>();442for (Enumeration<NetworkInterface> e = NetworkInterface443.getNetworkInterfaces(); e.hasMoreElements();) {444NetworkInterface netIF = e.nextElement();445for (Enumeration<InetAddress> iadrs = netIF.getInetAddresses(); iadrs446.hasMoreElements();) {447InetAddress iadr = iadrs.nextElement();448if (iadr instanceof Inet6Address) {449System.err.println("Test NetworkInterface: " + netIF);450Inet6Address i6adr = (Inet6Address) iadr;451System.err.println(" address " + iadr);452System.err.println(" scoped iface: "453+ i6adr.getScopedInterface());454// using this to actually set the hostName for an455// InetAddress456// created through the NetworkInterface457// have found that the fabricated instances has a null458// hostName459System.err.println(" hostName: " + i6adr.getHostName());460inet6Addresses.add(i6adr);461}462}463}464return inet6Addresses;465}466467static void assertHostNameEqual(String expectedHostName,468String deserializedHostName) {469System.err470.println("Inet6AddressSerializationTest.assertHostNameEqual:");471if (expectedHostName == null) {472if (deserializedHostName == null) {473// ok, do nothing.474} else {475System.err.println("Error checking " + " HostName, expected:"476+ expectedHostName + ", got :" + deserializedHostName);477failed = true;478}479} else if (!expectedHostName.equals(deserializedHostName)) {480System.err.println("Error checking "481+ // versionStr +482" HostName, expected:" + expectedHostName + ", got :"483+ deserializedHostName);484failed = true;485} else {486System.err.println("HostName equality "487+ // versionStr +488" HostName, expected:" + expectedHostName + ", got :"489+ deserializedHostName);490}491}492493static void assertHostAddressEqual(String expectedHostAddress,494String deserializedHostAddress) {495System.err496.println("Inet6AddressSerializationTest.assertHostAddressEqual:");497if (expectedHostAddress == null) {498if (deserializedHostAddress == null) {499// ok, do nothing.500} else {501System.err.println("Error checking "502+ " HostAddress, expected: " + expectedHostAddress503+ ", got: " + deserializedHostAddress);504failed = true;505}506} else if (!expectedHostAddress.equals(deserializedHostAddress)) {507System.err.println("Error checking "508+ // versionStr +509" HostAddress, expected: " + expectedHostAddress510+ ", got: " + deserializedHostAddress);511failed = true;512} else {513System.err.println("HostAddress equality "514+ // versionStr +515" HostAddress, expected: " + expectedHostAddress516+ ", got: " + deserializedHostAddress);517}518}519520static void assertAddressEqual(byte[] expectedAddress,521byte[] deserializedAddress) {522System.err.println("Inet6AddressSerializationTest.assertAddressEqual:");523if (expectedAddress == null) {524if (deserializedAddress == null) {525// ok, do nothing.526} else {527System.err.println("Error checking " + " Address, expected:"528+ Arrays.toString(expectedAddress) + ", got: "529+ Arrays.toString(deserializedAddress));530failed = true;531}532} else if (!Arrays.equals(expectedAddress, deserializedAddress)) {533System.err.println("Error checking "534+ // versionStr +535" Address, expected: " + Arrays.toString(expectedAddress)536+ ", got: " + Arrays.toString(deserializedAddress));537failed = true;538} else {539System.err.println("Address equality "540+ // versionStr +541" Address, expected: " + Arrays.toString(expectedAddress)542+ ", got: " + Arrays.toString(deserializedAddress));543}544}545546static void assertScopeIdEqual(int expectedScopeId, int deserializedScopeId) {547System.err.println("Inet6AddressSerializationTest.assertScopeIdEqual:");548if (expectedScopeId != deserializedScopeId) {549System.err.println("Error checking " + " ScopeId, expected:"550+ expectedScopeId + ", got: " + deserializedScopeId);551failed = true;552} else {553System.err.println("ScopeId equality "554+ // versionStr +555" ScopeId, expected: " + expectedScopeId + ", got: "556+ deserializedScopeId);557}558}559560static void assertNetworkInterfaceNameEqual(String expectedNetworkIfName,561NetworkInterface deserializedNetworkInterface) {562563if (deserializedNetworkInterface != null) {564String deserializedNetworkIfName = deserializedNetworkInterface565.getName();566System.err567.println("Inet6AddressSerializationTest.assertHostNameEqual:");568if (expectedNetworkIfName == null) {569if (deserializedNetworkIfName == null) {570// ok, do nothing.571} else {572System.err.println("Error checking "573+ " NetworkIfName, expected: "574+ expectedNetworkIfName + ", got: "575+ deserializedNetworkIfName);576failed = true;577}578} else if (!expectedNetworkIfName.equals(deserializedNetworkIfName)) {579System.err.println("Error checking "580+ " NetworkIfName, expected: " + expectedNetworkIfName581+ ", got: " + deserializedNetworkIfName);582failed = true;583} else {584System.err.println("NetworkIfName equality "585+ " NetworkIfName, expected: " + expectedNetworkIfName586+ ", got: " + deserializedNetworkIfName);587}588} else {589System.err590.println("Warning "591+ " NetworkInterface expected, but is null - ifname not relevant on deserializing host");592}593}594595static void assertNetworkInterfaceEqual(596NetworkInterface expectedNetworkInterface,597NetworkInterface deserializedNetworkInterface) {598System.err599.println("Inet6AddressSerializationTest.assertNetworkInterfaceEqual:");600if (expectedNetworkInterface == null) {601if (deserializedNetworkInterface == null) {602// ok, do nothing.603System.err.println("Network Interface equality "604+ " NetworkInterface, expected:"605+ expectedNetworkInterface + ", got :"606+ deserializedNetworkInterface);607} else {608System.err.println("Error checking "609+ " NetworkInterface, expected:"610+ expectedNetworkInterface + ", got :"611+ deserializedNetworkInterface);612failed = true;613}614} else if (!expectedNetworkInterface615.equals(deserializedNetworkInterface)) {616System.err.println("Error checking "617+ // versionStr +618" NetworkInterface, expected:" + expectedNetworkInterface619+ ", got :" + deserializedNetworkInterface);620failed = true;621} else {622System.err.println("Network Interface equality "623+ " NetworkInterface, expected:" + expectedNetworkInterface624+ ", got :" + deserializedNetworkInterface);625}626}627628static void equal(Object expected, Object got) {629if (expected == null) {630if (got == null) {631// ok, do nothing.632} else {633System.err.println("Error checking "634+ " serial data, expected:" + expected + ", got :"635+ got);636failed = true;637}638} else if (!expected.equals(got)) {639System.err.println("Error checking " + // versionStr +640" serial data, expected:" + expected + ", got :" + got);641failed = true;642}643}644645// Used to generate serialData.646static byte[] generateSerializedInet6AddressData(Inet6Address addr,647PrintStream out, boolean outputToFile) throws IOException {648ByteArrayOutputStream bos = new ByteArrayOutputStream();649try (ObjectOutputStream oos = new ObjectOutputStream(bos)) {650oos.writeObject(addr);651}652653String ifname = getIfName(addr);654byte[] ba = bos.toByteArray();655if (out != null) {656out.format("static final byte[] SerialData" + ifname + " = {\n");657for (int i = 0; i < ba.length; i++) {658out.format(" (byte)0x%02X", ba[i]);659if (i != (ba.length - 1))660out.format(",");661if (((i + 1) % 6) == 0)662out.format("\n");663}664out.format(" };\n \n");665}666if (outputToFile) {667serializeInet6AddressToFile(addr);668}669return ba;670}671672private static String getIfName(Inet6Address inet6Addr) {673String ifname;674if (inet6Addr.getScopedInterface() != null) {675ifname = "_ifname_" + inet6Addr.getScopedInterface().getName();676} else {677ifname = "_ifname_"678+ Integer.valueOf(inet6Addr.getScopeId()).toString();679}680return ifname;681}682683static void generateAllInet6AddressSerializedData() throws IOException {684// System.err.println("generateAllInet6AddressSerializedData: enter ....");685686List<Inet6Address> inet6Addresses;687688try {689inet6Addresses = getAllInet6Addresses();690} catch (Exception e) {691e.printStackTrace();692throw new IOException(e);693}694695for (Inet6Address inet6Address : inet6Addresses) {696generateSerializedInet6AddressData(inet6Address, System.out, true);697}698}699700static void serializeInet6AddressToFile(Inet6Address inet6Addr) {701702// System.err703// .println("serializeInet6AddressToIPV6AddressFile: enter ....");704705FileOutputStream fOut = null;706String inet6AddressOutputFilename = null;707inet6AddressOutputFilename = createOutputFileName(inet6Addr);708try {709fOut = new FileOutputStream(inet6AddressOutputFilename);710} catch (FileNotFoundException fnfEx) {711712fnfEx.printStackTrace();713}714ObjectOutputStream ooStream = null;715try {716if (fOut != null) {717ooStream = new ObjectOutputStream(fOut);718} else {719System.err.println("Problem initilising Object output stream ");720System.exit(-1);721}722723} catch (IOException e) {724e.printStackTrace();725System.exit(-1);726}727728// serialise the last Inet6Address729/*730* System.err731* .println("serializeInet6AddressToIPV6AddressFile scoped iface: \n" +732* inet6Addr.getScopedInterface());733*/734try {735ooStream.writeObject(inet6Addr);736} catch (Exception ex) {737ex.printStackTrace();738System.exit(-1);739}740741try {742ooStream.close();743} catch (IOException e) {744e.printStackTrace();745}746}747748private static String createOutputFileName(Inet6Address inet6Addr) {749String inet6AddressOutputFilename;750if (inet6Addr.getScopedInterface() != null) {751inet6AddressOutputFilename = "IPV6Address_"752+ inet6Addr.getScopedInterface().getName() + ".out";753} else {754inet6AddressOutputFilename = "IPV6Address_"755+ Integer.valueOf(inet6Addr.getScopeId()).toString()756+ ".out";757}758return inet6AddressOutputFilename;759}760761// --- Generated data ---762// JDK7 output java Inet6AddressSerializationTest generate.763764// loopback lo0 interface on Solaris 10765766static final byte[] JDK7Inet6AddressSerialData = { (byte) 0xAC,767(byte) 0xED, (byte) 0x00, (byte) 0x05, (byte) 0x73, (byte) 0x72,768(byte) 0x00, (byte) 0x15, (byte) 0x6A, (byte) 0x61, (byte) 0x76,769(byte) 0x61, (byte) 0x2E, (byte) 0x6E, (byte) 0x65, (byte) 0x74,770(byte) 0x2E, (byte) 0x49, (byte) 0x6E, (byte) 0x65, (byte) 0x74,771(byte) 0x36, (byte) 0x41, (byte) 0x64, (byte) 0x64, (byte) 0x72,772(byte) 0x65, (byte) 0x73, (byte) 0x73, (byte) 0x5F, (byte) 0x7C,773(byte) 0x20, (byte) 0x81, (byte) 0x52, (byte) 0x2C, (byte) 0x80,774(byte) 0x21, (byte) 0x03, (byte) 0x00, (byte) 0x05, (byte) 0x49,775(byte) 0x00, (byte) 0x08, (byte) 0x73, (byte) 0x63, (byte) 0x6F,776(byte) 0x70, (byte) 0x65, (byte) 0x5F, (byte) 0x69, (byte) 0x64,777(byte) 0x5A, (byte) 0x00, (byte) 0x0C, (byte) 0x73, (byte) 0x63,778(byte) 0x6F, (byte) 0x70, (byte) 0x65, (byte) 0x5F, (byte) 0x69,779(byte) 0x64, (byte) 0x5F, (byte) 0x73, (byte) 0x65, (byte) 0x74,780(byte) 0x5A, (byte) 0x00, (byte) 0x10, (byte) 0x73, (byte) 0x63,781(byte) 0x6F, (byte) 0x70, (byte) 0x65, (byte) 0x5F, (byte) 0x69,782(byte) 0x66, (byte) 0x6E, (byte) 0x61, (byte) 0x6D, (byte) 0x65,783(byte) 0x5F, (byte) 0x73, (byte) 0x65, (byte) 0x74, (byte) 0x4C,784(byte) 0x00, (byte) 0x06, (byte) 0x69, (byte) 0x66, (byte) 0x6E,785(byte) 0x61, (byte) 0x6D, (byte) 0x65, (byte) 0x74, (byte) 0x00,786(byte) 0x12, (byte) 0x4C, (byte) 0x6A, (byte) 0x61, (byte) 0x76,787(byte) 0x61, (byte) 0x2F, (byte) 0x6C, (byte) 0x61, (byte) 0x6E,788(byte) 0x67, (byte) 0x2F, (byte) 0x53, (byte) 0x74, (byte) 0x72,789(byte) 0x69, (byte) 0x6E, (byte) 0x67, (byte) 0x3B, (byte) 0x5B,790(byte) 0x00, (byte) 0x09, (byte) 0x69, (byte) 0x70, (byte) 0x61,791(byte) 0x64, (byte) 0x64, (byte) 0x72, (byte) 0x65, (byte) 0x73,792(byte) 0x73, (byte) 0x74, (byte) 0x00, (byte) 0x02, (byte) 0x5B,793(byte) 0x42, (byte) 0x78, (byte) 0x72, (byte) 0x00, (byte) 0x14,794(byte) 0x6A, (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2E,795(byte) 0x6E, (byte) 0x65, (byte) 0x74, (byte) 0x2E, (byte) 0x49,796(byte) 0x6E, (byte) 0x65, (byte) 0x74, (byte) 0x41, (byte) 0x64,797(byte) 0x64, (byte) 0x72, (byte) 0x65, (byte) 0x73, (byte) 0x73,798(byte) 0x2D, (byte) 0x9B, (byte) 0x57, (byte) 0xAF, (byte) 0x9F,799(byte) 0xE3, (byte) 0xEB, (byte) 0xDB, (byte) 0x02, (byte) 0x00,800(byte) 0x03, (byte) 0x49, (byte) 0x00, (byte) 0x07, (byte) 0x61,801(byte) 0x64, (byte) 0x64, (byte) 0x72, (byte) 0x65, (byte) 0x73,802(byte) 0x73, (byte) 0x49, (byte) 0x00, (byte) 0x06, (byte) 0x66,803(byte) 0x61, (byte) 0x6D, (byte) 0x69, (byte) 0x6C, (byte) 0x79,804(byte) 0x4C, (byte) 0x00, (byte) 0x08, (byte) 0x68, (byte) 0x6F,805(byte) 0x73, (byte) 0x74, (byte) 0x4E, (byte) 0x61, (byte) 0x6D,806(byte) 0x65, (byte) 0x71, (byte) 0x00, (byte) 0x7E, (byte) 0x00,807(byte) 0x01, (byte) 0x78, (byte) 0x70, (byte) 0x00, (byte) 0x00,808(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,809(byte) 0x02, (byte) 0x74, (byte) 0x00, (byte) 0x09, (byte) 0x6C,810(byte) 0x6F, (byte) 0x63, (byte) 0x61, (byte) 0x6C, (byte) 0x68,811(byte) 0x6F, (byte) 0x73, (byte) 0x74, (byte) 0x00, (byte) 0x00,812(byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x70,813(byte) 0x75, (byte) 0x72, (byte) 0x00, (byte) 0x02, (byte) 0x5B,814(byte) 0x42, (byte) 0xAC, (byte) 0xF3, (byte) 0x17, (byte) 0xF8,815(byte) 0x06, (byte) 0x08, (byte) 0x54, (byte) 0xE0, (byte) 0x02,816(byte) 0x00, (byte) 0x00, (byte) 0x78, (byte) 0x70, (byte) 0x00,817(byte) 0x00, (byte) 0x00, (byte) 0x10, (byte) 0x00, (byte) 0x00,818(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,819(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,820(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x78 };821822// JDK8 output java Inet6AddressSerializationTest generate.823// loopback lo0 interface on Solaris 10824825static final byte[] JDK8Inet6AddressSerialData = { (byte) 0xAC,826(byte) 0xED, (byte) 0x00, (byte) 0x05, (byte) 0x73, (byte) 0x72,827(byte) 0x00, (byte) 0x15, (byte) 0x6A, (byte) 0x61, (byte) 0x76,828(byte) 0x61, (byte) 0x2E, (byte) 0x6E, (byte) 0x65, (byte) 0x74,829(byte) 0x2E, (byte) 0x49, (byte) 0x6E, (byte) 0x65, (byte) 0x74,830(byte) 0x36, (byte) 0x41, (byte) 0x64, (byte) 0x64, (byte) 0x72,831(byte) 0x65, (byte) 0x73, (byte) 0x73, (byte) 0x5F, (byte) 0x7C,832(byte) 0x20, (byte) 0x81, (byte) 0x52, (byte) 0x2C, (byte) 0x80,833(byte) 0x21, (byte) 0x03, (byte) 0x00, (byte) 0x05, (byte) 0x49,834(byte) 0x00, (byte) 0x08, (byte) 0x73, (byte) 0x63, (byte) 0x6F,835(byte) 0x70, (byte) 0x65, (byte) 0x5F, (byte) 0x69, (byte) 0x64,836(byte) 0x5A, (byte) 0x00, (byte) 0x0C, (byte) 0x73, (byte) 0x63,837(byte) 0x6F, (byte) 0x70, (byte) 0x65, (byte) 0x5F, (byte) 0x69,838(byte) 0x64, (byte) 0x5F, (byte) 0x73, (byte) 0x65, (byte) 0x74,839(byte) 0x5A, (byte) 0x00, (byte) 0x10, (byte) 0x73, (byte) 0x63,840(byte) 0x6F, (byte) 0x70, (byte) 0x65, (byte) 0x5F, (byte) 0x69,841(byte) 0x66, (byte) 0x6E, (byte) 0x61, (byte) 0x6D, (byte) 0x65,842(byte) 0x5F, (byte) 0x73, (byte) 0x65, (byte) 0x74, (byte) 0x4C,843(byte) 0x00, (byte) 0x06, (byte) 0x69, (byte) 0x66, (byte) 0x6E,844(byte) 0x61, (byte) 0x6D, (byte) 0x65, (byte) 0x74, (byte) 0x00,845(byte) 0x12, (byte) 0x4C, (byte) 0x6A, (byte) 0x61, (byte) 0x76,846(byte) 0x61, (byte) 0x2F, (byte) 0x6C, (byte) 0x61, (byte) 0x6E,847(byte) 0x67, (byte) 0x2F, (byte) 0x53, (byte) 0x74, (byte) 0x72,848(byte) 0x69, (byte) 0x6E, (byte) 0x67, (byte) 0x3B, (byte) 0x5B,849(byte) 0x00, (byte) 0x09, (byte) 0x69, (byte) 0x70, (byte) 0x61,850(byte) 0x64, (byte) 0x64, (byte) 0x72, (byte) 0x65, (byte) 0x73,851(byte) 0x73, (byte) 0x74, (byte) 0x00, (byte) 0x02, (byte) 0x5B,852(byte) 0x42, (byte) 0x78, (byte) 0x72, (byte) 0x00, (byte) 0x14,853(byte) 0x6A, (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2E,854(byte) 0x6E, (byte) 0x65, (byte) 0x74, (byte) 0x2E, (byte) 0x49,855(byte) 0x6E, (byte) 0x65, (byte) 0x74, (byte) 0x41, (byte) 0x64,856(byte) 0x64, (byte) 0x72, (byte) 0x65, (byte) 0x73, (byte) 0x73,857(byte) 0x2D, (byte) 0x9B, (byte) 0x57, (byte) 0xAF, (byte) 0x9F,858(byte) 0xE3, (byte) 0xEB, (byte) 0xDB, (byte) 0x02, (byte) 0x00,859(byte) 0x03, (byte) 0x49, (byte) 0x00, (byte) 0x07, (byte) 0x61,860(byte) 0x64, (byte) 0x64, (byte) 0x72, (byte) 0x65, (byte) 0x73,861(byte) 0x73, (byte) 0x49, (byte) 0x00, (byte) 0x06, (byte) 0x66,862(byte) 0x61, (byte) 0x6D, (byte) 0x69, (byte) 0x6C, (byte) 0x79,863(byte) 0x4C, (byte) 0x00, (byte) 0x08, (byte) 0x68, (byte) 0x6F,864(byte) 0x73, (byte) 0x74, (byte) 0x4E, (byte) 0x61, (byte) 0x6D,865(byte) 0x65, (byte) 0x71, (byte) 0x00, (byte) 0x7E, (byte) 0x00,866(byte) 0x01, (byte) 0x78, (byte) 0x70, (byte) 0x00, (byte) 0x00,867(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,868(byte) 0x02, (byte) 0x74, (byte) 0x00, (byte) 0x09, (byte) 0x6C,869(byte) 0x6F, (byte) 0x63, (byte) 0x61, (byte) 0x6C, (byte) 0x68,870(byte) 0x6F, (byte) 0x73, (byte) 0x74, (byte) 0x00, (byte) 0x00,871(byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x70,872(byte) 0x75, (byte) 0x72, (byte) 0x00, (byte) 0x02, (byte) 0x5B,873(byte) 0x42, (byte) 0xAC, (byte) 0xF3, (byte) 0x17, (byte) 0xF8,874(byte) 0x06, (byte) 0x08, (byte) 0x54, (byte) 0xE0, (byte) 0x02,875(byte) 0x00, (byte) 0x00, (byte) 0x78, (byte) 0x70, (byte) 0x00,876(byte) 0x00, (byte) 0x00, (byte) 0x10, (byte) 0x00, (byte) 0x00,877(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,878(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,879(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x78 };880881// java Inet6AddressSerializationTest generateAll produces this inet6address882// serial data883// jdk8 generated serialization of on address fe80:0:0:0:21b:24ff:febd:f29c884// net if e1000g0885886static final byte[] SerialData_ifname_e1000g0 = { (byte) 0xAC, (byte) 0xED,887(byte) 0x00, (byte) 0x05, (byte) 0x73, (byte) 0x72, (byte) 0x00,888(byte) 0x15, (byte) 0x6A, (byte) 0x61, (byte) 0x76, (byte) 0x61,889(byte) 0x2E, (byte) 0x6E, (byte) 0x65, (byte) 0x74, (byte) 0x2E,890(byte) 0x49, (byte) 0x6E, (byte) 0x65, (byte) 0x74, (byte) 0x36,891(byte) 0x41, (byte) 0x64, (byte) 0x64, (byte) 0x72, (byte) 0x65,892(byte) 0x73, (byte) 0x73, (byte) 0x5F, (byte) 0x7C, (byte) 0x20,893(byte) 0x81, (byte) 0x52, (byte) 0x2C, (byte) 0x80, (byte) 0x21,894(byte) 0x03, (byte) 0x00, (byte) 0x05, (byte) 0x49, (byte) 0x00,895(byte) 0x08, (byte) 0x73, (byte) 0x63, (byte) 0x6F, (byte) 0x70,896(byte) 0x65, (byte) 0x5F, (byte) 0x69, (byte) 0x64, (byte) 0x5A,897(byte) 0x00, (byte) 0x0C, (byte) 0x73, (byte) 0x63, (byte) 0x6F,898(byte) 0x70, (byte) 0x65, (byte) 0x5F, (byte) 0x69, (byte) 0x64,899(byte) 0x5F, (byte) 0x73, (byte) 0x65, (byte) 0x74, (byte) 0x5A,900(byte) 0x00, (byte) 0x10, (byte) 0x73, (byte) 0x63, (byte) 0x6F,901(byte) 0x70, (byte) 0x65, (byte) 0x5F, (byte) 0x69, (byte) 0x66,902(byte) 0x6E, (byte) 0x61, (byte) 0x6D, (byte) 0x65, (byte) 0x5F,903(byte) 0x73, (byte) 0x65, (byte) 0x74, (byte) 0x4C, (byte) 0x00,904(byte) 0x06, (byte) 0x69, (byte) 0x66, (byte) 0x6E, (byte) 0x61,905(byte) 0x6D, (byte) 0x65, (byte) 0x74, (byte) 0x00, (byte) 0x12,906(byte) 0x4C, (byte) 0x6A, (byte) 0x61, (byte) 0x76, (byte) 0x61,907(byte) 0x2F, (byte) 0x6C, (byte) 0x61, (byte) 0x6E, (byte) 0x67,908(byte) 0x2F, (byte) 0x53, (byte) 0x74, (byte) 0x72, (byte) 0x69,909(byte) 0x6E, (byte) 0x67, (byte) 0x3B, (byte) 0x5B, (byte) 0x00,910(byte) 0x09, (byte) 0x69, (byte) 0x70, (byte) 0x61, (byte) 0x64,911(byte) 0x64, (byte) 0x72, (byte) 0x65, (byte) 0x73, (byte) 0x73,912(byte) 0x74, (byte) 0x00, (byte) 0x02, (byte) 0x5B, (byte) 0x42,913(byte) 0x78, (byte) 0x72, (byte) 0x00, (byte) 0x14, (byte) 0x6A,914(byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2E, (byte) 0x6E,915(byte) 0x65, (byte) 0x74, (byte) 0x2E, (byte) 0x49, (byte) 0x6E,916(byte) 0x65, (byte) 0x74, (byte) 0x41, (byte) 0x64, (byte) 0x64,917(byte) 0x72, (byte) 0x65, (byte) 0x73, (byte) 0x73, (byte) 0x2D,918(byte) 0x9B, (byte) 0x57, (byte) 0xAF, (byte) 0x9F, (byte) 0xE3,919(byte) 0xEB, (byte) 0xDB, (byte) 0x02, (byte) 0x00, (byte) 0x03,920(byte) 0x49, (byte) 0x00, (byte) 0x07, (byte) 0x61, (byte) 0x64,921(byte) 0x64, (byte) 0x72, (byte) 0x65, (byte) 0x73, (byte) 0x73,922(byte) 0x49, (byte) 0x00, (byte) 0x06, (byte) 0x66, (byte) 0x61,923(byte) 0x6D, (byte) 0x69, (byte) 0x6C, (byte) 0x79, (byte) 0x4C,924(byte) 0x00, (byte) 0x08, (byte) 0x68, (byte) 0x6F, (byte) 0x73,925(byte) 0x74, (byte) 0x4E, (byte) 0x61, (byte) 0x6D, (byte) 0x65,926(byte) 0x71, (byte) 0x00, (byte) 0x7E, (byte) 0x00, (byte) 0x01,927(byte) 0x78, (byte) 0x70, (byte) 0x00, (byte) 0x00, (byte) 0x00,928(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x02,929(byte) 0x74, (byte) 0x00, (byte) 0x25, (byte) 0x66, (byte) 0x65,930(byte) 0x38, (byte) 0x30, (byte) 0x3A, (byte) 0x30, (byte) 0x3A,931(byte) 0x30, (byte) 0x3A, (byte) 0x30, (byte) 0x3A, (byte) 0x32,932(byte) 0x31, (byte) 0x62, (byte) 0x3A, (byte) 0x32, (byte) 0x34,933(byte) 0x66, (byte) 0x66, (byte) 0x3A, (byte) 0x66, (byte) 0x65,934(byte) 0x62, (byte) 0x64, (byte) 0x3A, (byte) 0x66, (byte) 0x32,935(byte) 0x39, (byte) 0x63, (byte) 0x25, (byte) 0x65, (byte) 0x31,936(byte) 0x30, (byte) 0x30, (byte) 0x30, (byte) 0x67, (byte) 0x30,937(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x02, (byte) 0x01,938(byte) 0x01, (byte) 0x74, (byte) 0x00, (byte) 0x07, (byte) 0x65,939(byte) 0x31, (byte) 0x30, (byte) 0x30, (byte) 0x30, (byte) 0x67,940(byte) 0x30, (byte) 0x75, (byte) 0x72, (byte) 0x00, (byte) 0x02,941(byte) 0x5B, (byte) 0x42, (byte) 0xAC, (byte) 0xF3, (byte) 0x17,942(byte) 0xF8, (byte) 0x06, (byte) 0x08, (byte) 0x54, (byte) 0xE0,943(byte) 0x02, (byte) 0x00, (byte) 0x00, (byte) 0x78, (byte) 0x70,944(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x10, (byte) 0xFE,945(byte) 0x80, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,946(byte) 0x00, (byte) 0x00, (byte) 0x02, (byte) 0x1B, (byte) 0x24,947(byte) 0xFF, (byte) 0xFE, (byte) 0xBD, (byte) 0xF2, (byte) 0x9C,948(byte) 0x78 };949950// jdk8 generated serialization of address 0::1 on net if lo0 hostname951// localhost scope_id 1952953static final byte[] SerialData_ifname_lo0 = { (byte) 0xAC, (byte) 0xED,954(byte) 0x00, (byte) 0x05, (byte) 0x73, (byte) 0x72, (byte) 0x00,955(byte) 0x15, (byte) 0x6A, (byte) 0x61, (byte) 0x76, (byte) 0x61,956(byte) 0x2E, (byte) 0x6E, (byte) 0x65, (byte) 0x74, (byte) 0x2E,957(byte) 0x49, (byte) 0x6E, (byte) 0x65, (byte) 0x74, (byte) 0x36,958(byte) 0x41, (byte) 0x64, (byte) 0x64, (byte) 0x72, (byte) 0x65,959(byte) 0x73, (byte) 0x73, (byte) 0x5F, (byte) 0x7C, (byte) 0x20,960(byte) 0x81, (byte) 0x52, (byte) 0x2C, (byte) 0x80, (byte) 0x21,961(byte) 0x03, (byte) 0x00, (byte) 0x05, (byte) 0x49, (byte) 0x00,962(byte) 0x08, (byte) 0x73, (byte) 0x63, (byte) 0x6F, (byte) 0x70,963(byte) 0x65, (byte) 0x5F, (byte) 0x69, (byte) 0x64, (byte) 0x5A,964(byte) 0x00, (byte) 0x0C, (byte) 0x73, (byte) 0x63, (byte) 0x6F,965(byte) 0x70, (byte) 0x65, (byte) 0x5F, (byte) 0x69, (byte) 0x64,966(byte) 0x5F, (byte) 0x73, (byte) 0x65, (byte) 0x74, (byte) 0x5A,967(byte) 0x00, (byte) 0x10, (byte) 0x73, (byte) 0x63, (byte) 0x6F,968(byte) 0x70, (byte) 0x65, (byte) 0x5F, (byte) 0x69, (byte) 0x66,969(byte) 0x6E, (byte) 0x61, (byte) 0x6D, (byte) 0x65, (byte) 0x5F,970(byte) 0x73, (byte) 0x65, (byte) 0x74, (byte) 0x4C, (byte) 0x00,971(byte) 0x06, (byte) 0x69, (byte) 0x66, (byte) 0x6E, (byte) 0x61,972(byte) 0x6D, (byte) 0x65, (byte) 0x74, (byte) 0x00, (byte) 0x12,973(byte) 0x4C, (byte) 0x6A, (byte) 0x61, (byte) 0x76, (byte) 0x61,974(byte) 0x2F, (byte) 0x6C, (byte) 0x61, (byte) 0x6E, (byte) 0x67,975(byte) 0x2F, (byte) 0x53, (byte) 0x74, (byte) 0x72, (byte) 0x69,976(byte) 0x6E, (byte) 0x67, (byte) 0x3B, (byte) 0x5B, (byte) 0x00,977(byte) 0x09, (byte) 0x69, (byte) 0x70, (byte) 0x61, (byte) 0x64,978(byte) 0x64, (byte) 0x72, (byte) 0x65, (byte) 0x73, (byte) 0x73,979(byte) 0x74, (byte) 0x00, (byte) 0x02, (byte) 0x5B, (byte) 0x42,980(byte) 0x78, (byte) 0x72, (byte) 0x00, (byte) 0x14, (byte) 0x6A,981(byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2E, (byte) 0x6E,982(byte) 0x65, (byte) 0x74, (byte) 0x2E, (byte) 0x49, (byte) 0x6E,983(byte) 0x65, (byte) 0x74, (byte) 0x41, (byte) 0x64, (byte) 0x64,984(byte) 0x72, (byte) 0x65, (byte) 0x73, (byte) 0x73, (byte) 0x2D,985(byte) 0x9B, (byte) 0x57, (byte) 0xAF, (byte) 0x9F, (byte) 0xE3,986(byte) 0xEB, (byte) 0xDB, (byte) 0x02, (byte) 0x00, (byte) 0x03,987(byte) 0x49, (byte) 0x00, (byte) 0x07, (byte) 0x61, (byte) 0x64,988(byte) 0x64, (byte) 0x72, (byte) 0x65, (byte) 0x73, (byte) 0x73,989(byte) 0x49, (byte) 0x00, (byte) 0x06, (byte) 0x66, (byte) 0x61,990(byte) 0x6D, (byte) 0x69, (byte) 0x6C, (byte) 0x79, (byte) 0x4C,991(byte) 0x00, (byte) 0x08, (byte) 0x68, (byte) 0x6F, (byte) 0x73,992(byte) 0x74, (byte) 0x4E, (byte) 0x61, (byte) 0x6D, (byte) 0x65,993(byte) 0x71, (byte) 0x00, (byte) 0x7E, (byte) 0x00, (byte) 0x01,994(byte) 0x78, (byte) 0x70, (byte) 0x00, (byte) 0x00, (byte) 0x00,995(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x02,996(byte) 0x74, (byte) 0x00, (byte) 0x09, (byte) 0x6C, (byte) 0x6F,997(byte) 0x63, (byte) 0x61, (byte) 0x6C, (byte) 0x68, (byte) 0x6F,998(byte) 0x73, (byte) 0x74, (byte) 0x00, (byte) 0x00, (byte) 0x00,999(byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x74, (byte) 0x00,1000(byte) 0x03, (byte) 0x6C, (byte) 0x6F, (byte) 0x30, (byte) 0x75,1001(byte) 0x72, (byte) 0x00, (byte) 0x02, (byte) 0x5B, (byte) 0x42,1002(byte) 0xAC, (byte) 0xF3, (byte) 0x17, (byte) 0xF8, (byte) 0x06,1003(byte) 0x08, (byte) 0x54, (byte) 0xE0, (byte) 0x02, (byte) 0x00,1004(byte) 0x00, (byte) 0x78, (byte) 0x70, (byte) 0x00, (byte) 0x00,1005(byte) 0x00, (byte) 0x10, (byte) 0x00, (byte) 0x00, (byte) 0x00,1006(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,1007(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,1008(byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x78 };10091010}10111012class MockLo0Inet6Address {10131014private static final byte[] LOOPBACKIPV6ADDRESS = { (byte) 0x00,1015(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,1016(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,1017(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01 };10181019private static final String LOCALHOSTNAME = "localhost";10201021private static final String LO0HOSTADDRESS = "0:0:0:0:0:0:0:1%lo0";10221023private static final String BARE_LO0HOSTADDRESS = "0:0:0:0:0:0:0:1";10241025private static final String LO0HOSTADDRESS_WITHINDEX = "0:0:0:0:0:0:0:1%1";10261027private static final int SCOPE_ID_LO0 = 1;10281029private static final int SCOPE_ID_ZERO = 0;10301031public static final String NETWORK_IF_LO0 = "lo0";10321033static String getHostName() {1034return LOCALHOSTNAME;1035}10361037static String getHostAddress() {1038return LO0HOSTADDRESS;1039}10401041static String getBareHostAddress() {1042return BARE_LO0HOSTADDRESS;1043}10441045static String getHostAddressWithIndex() {1046return LO0HOSTADDRESS_WITHINDEX;1047}10481049static byte[] getAddress() {1050return LOOPBACKIPV6ADDRESS;1051}10521053static int getScopeId() {1054return SCOPE_ID_LO0;1055}10561057static int getScopeZero() {1058return SCOPE_ID_ZERO;1059}10601061static String getScopeIfName() {1062return NETWORK_IF_LO0;1063}10641065}10661067class MockE1000g0Inet6Address {10681069// fe80::21b:24ff:febd:f29c1070private static final byte[] E1000G0IPV6ADDRESS = { (byte) 0xfe,1071(byte) 0x80, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,1072(byte) 0x00, (byte) 0x00, (byte) 0x02, (byte) 0x1b, (byte) 0x24,1073(byte) 0xff, (byte) 0xfe, (byte) 0xbd, (byte) 0xf2, (byte) 0x9c };10741075private static final String E1000G0HOSTNAME = "fe80:0:0:0:21b:24ff:febd:f29c%e1000g0";10761077private static final String BARE_E1000G0HOSTADDRESS = "fe80:0:0:0:21b:24ff:febd:f29c";10781079private static final String E1000G0HOSTADDRESS_WITHINDEX = "fe80:0:0:0:21b:24ff:febd:f29c%2";10801081private static final String E1000G0HOSTADDRESS = "fe80:0:0:0:21b:24ff:febd:f29c%e1000g0";10821083private static final String NETWORK_IF_E1000G0 = "e1000g0";10841085private static final int SCOPE_ID_E1000G0 = 2;10861087private static final int SCOPE_ID_ZERO = 0;10881089static String getHostName() {1090return E1000G0HOSTNAME;1091}10921093static String getHostAddress() {1094return E1000G0HOSTADDRESS;1095}10961097static String getHostAddressWithIndex() {1098return E1000G0HOSTADDRESS_WITHINDEX;1099}11001101static String getBareHostAddress() {1102return BARE_E1000G0HOSTADDRESS;1103}11041105static byte[] getAddress() {1106return E1000G0IPV6ADDRESS;1107}11081109static int getScopeId() {1110return SCOPE_ID_E1000G0;1111}11121113static int getScopeZero() {1114return SCOPE_ID_ZERO;1115}11161117static String getScopeIfName() {1118return NETWORK_IF_E1000G0;1119}11201121}112211231124