Path: blob/master/test/jdk/java/net/Inet6Address/serialize/Inet6AddressSerializationTest.java
41152 views
/*1* Copyright (c) 2015, 2018, 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;4950static boolean isWindows = System.getProperty("os.name").startsWith("Windows");5152public static final int LOOPBACK_SCOPE_ID = 0;5354public static final byte[] IN6ADDR_ANY_INIT = { (byte) 0x00, (byte) 0x00,55(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,56(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,57(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 };5859public static final byte[] LOOPBACKIPV6ADDRESS = { (byte) 0x00,60(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,61(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,62(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01 };6364// fe80::21b:24ff:febd:f29c65public static final byte[] E1000G0IPV6ADDRESS = { (byte) 0xfe, (byte) 0x80,66(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,67(byte) 0x00, (byte) 0x02, (byte) 0x1b, (byte) 0x24, (byte) 0xff,68(byte) 0xfe, (byte) 0xbd, (byte) 0xf2, (byte) 0x9c };6970public static final String E1000G0HOSTNAME = "fe80:0:0:0:21b:24ff:febd:f29c%e1000g0";7172public static final String LOCALHOSTNAME = "localhost";7374public static final String NETWORK_IF_E1000G0 = "e1000g0";7576public static final String NETWORK_IF_LO0 = "lo0";7778public static final int SCOPE_ID_E1000G0 = 2;7980public static final int SCOPE_ID_LO0 = 1;8182public static final int SCOPE_ID_ZERO = 0;8384public static void main(String[] args) throws Exception {85// args[0] == generate-loopback generates serial data for loopback if86// args[0] == generateAll generates serial data for interfaces with an87// IPV6 address binding8889if (args.length != 0) {9091if (args[0].equals("generate-loopback")) {9293generateSerializedInet6AddressData(Inet6Address.getByAddress(94InetAddress.getLoopbackAddress().getHostName(),95LOOPBACKIPV6ADDRESS, LOOPBACK_SCOPE_ID), System.out,96true);9798} else {99generateAllInet6AddressSerializedData();100}101} else {102runTests();103}104}105106private static void runTests() throws UnknownHostException, Exception,107IOException {108byte[] thisHostIPV6Address = null;109int scope_id = LOOPBACK_SCOPE_ID;110111System.out.println("Hostname: "112+ InetAddress.getLocalHost().getHostName());113System.out.println("LocalHost isLoopback : "114+ InetAddress.getLocalHost().isLoopbackAddress());115thisHostIPV6Address = getThisHostIPV6Address(InetAddress.getLocalHost()116.getHostName());117118if (thisHostIPV6Address == null) {119thisHostIPV6Address = IN6ADDR_ANY_INIT;120}121122// testing JDK7 generated serialized loopback against locally generated123// loopback address124testInet6AddressSerialization(Inet6Address.getByAddress(InetAddress125.getLoopbackAddress().getHostName(), LOOPBACKIPV6ADDRESS,126scope_id), JDK7Inet6AddressSerialData);127// testing JDK8 generated serialized loopback against locally generated128// loopback address129testInet6AddressSerialization(Inet6Address.getByAddress(InetAddress130.getLoopbackAddress().getHostName(), LOOPBACKIPV6ADDRESS,131scope_id), JDK8Inet6AddressSerialData);132testInet6AddressSerialization(Inet6Address.getByAddress(InetAddress133.getLocalHost().getHostName(), IN6ADDR_ANY_INIT, scope_id),134null);135testInet6AddressSerialization(Inet6Address.getByAddress(InetAddress136.getLocalHost().getHostName(), thisHostIPV6Address, scope_id),137null);138testAllNetworkInterfaces();139140// test against lo0141testSerializedLo0Inet6Address();142143testSerializedE1000gInet6Address();144145if (failed)146throw new RuntimeException("Some tests failed, check output");147}148149private static byte[] getThisHostIPV6Address(String hostName)150throws Exception {151InetAddress[] thisHostIPAddresses = null;152try {153thisHostIPAddresses = InetAddress.getAllByName(InetAddress154.getLocalHost().getHostName());155} catch (UnknownHostException uhEx) {156uhEx.printStackTrace();157throw uhEx;158}159byte[] thisHostIPV6Address = null;160for (InetAddress inetAddress : thisHostIPAddresses) {161if (inetAddress instanceof Inet6Address) {162if (inetAddress.getHostName().equals(hostName)) {163thisHostIPV6Address = inetAddress.getAddress();164break;165}166}167}168// System.err.println("getThisHostIPV6Address: address is "169// + Arrays.toString(thisHostIPV6Address));170return thisHostIPV6Address;171}172173static void testAllNetworkInterfaces() throws Exception {174System.err.println("\n testAllNetworkInterfaces: \n ");175for (Enumeration<NetworkInterface> e = NetworkInterface176.getNetworkInterfaces(); e.hasMoreElements();) {177NetworkInterface netIF = e.nextElement();178// Skip (Windows)Teredo Tunneling Pseudo-Interface179if (isWindows) {180String dName = netIF.getDisplayName();181if (dName != null && dName.contains("Teredo")) {182continue;183}184}185for (Enumeration<InetAddress> iadrs = netIF.getInetAddresses(); iadrs186.hasMoreElements();) {187InetAddress iadr = iadrs.nextElement();188if (iadr instanceof Inet6Address) {189System.err.println("Test NetworkInterface: " + netIF);190Inet6Address i6adr = (Inet6Address) iadr;191System.err.println("Testing with " + iadr);192System.err.println(" scoped iface: "193+ i6adr.getScopedInterface());194System.err.println(" hostname: " + i6adr.getHostName());195testInet6AddressSerialization(i6adr, null);196}197}198}199}200201static void displayExpectedInet6Address(Inet6Address expectedInet6Address) {202203String expectedHostName = expectedInet6Address.getHostName();204byte[] expectedAddress = expectedInet6Address.getAddress();205String expectedHostAddress = expectedInet6Address.getHostAddress();206int expectedScopeId = expectedInet6Address.getScopeId();207NetworkInterface expectedNetIf = expectedInet6Address208.getScopedInterface();209210System.err.println("Excpected HostName: " + expectedHostName);211System.err.println("Expected Address: "212+ Arrays.toString(expectedAddress));213System.err.println("Expected HostAddress: " + expectedHostAddress);214System.err.println("Expected Scope Id " + expectedScopeId);215System.err.println("Expected NetworkInterface " + expectedNetIf);216System.err.println("Expected Inet6Address " + expectedInet6Address);217}218219// test serialization deserialization of Inet6Address220static void testInet6AddressSerialization(221Inet6Address expectedInet6Address, byte[] serializedAddress)222throws IOException {223System.err.println("\n testInet6AddressSerialization: enter \n");224225// displayExpectedInet6Address(expectedInet6Address);226227byte[] serialData = serializedAddress != null ? serializedAddress228: generateSerializedInet6AddressData(expectedInet6Address,229null, false);230try (ByteArrayInputStream bis = new ByteArrayInputStream(serialData);231ObjectInputStream oin = new ObjectInputStream(bis)) {232Inet6Address deserializedIPV6Addr = (Inet6Address) oin.readObject();233System.err.println("Deserialized Inet6Address "234+ deserializedIPV6Addr);235assertHostNameEqual(expectedInet6Address.getHostName(),236deserializedIPV6Addr.getHostName());237assertHostAddressEqual(expectedInet6Address.getHostAddress(),238deserializedIPV6Addr.getHostAddress());239assertAddressEqual(expectedInet6Address.getAddress(),240deserializedIPV6Addr.getAddress());241assertScopeIdEqual(expectedInet6Address.getScopeId(),242deserializedIPV6Addr.getScopeId());243assertNetworkInterfaceEqual(244expectedInet6Address.getScopedInterface(),245deserializedIPV6Addr.getScopedInterface());246} catch (Exception e) {247System.err.println("Exception caught during deserialization");248failed = true;249e.printStackTrace();250}251}252253static void testSerializedE1000gInet6Address() throws IOException {254System.err.println("\n testSerializedE1000gInet6Address: enter \n");255boolean testWithNetIf = true;256boolean useMockInet6Address = false;257258NetworkInterface testNetIf = NetworkInterface259.getByName(NETWORK_IF_E1000G0);260Inet6Address expectedInet6Address = null;261if (testNetIf != null) {262System.err263.println("\n testSerializedE1000gInet6Address: using netif \n");264try {265expectedInet6Address = Inet6Address.getByAddress(266E1000G0HOSTNAME, E1000G0IPV6ADDRESS, testNetIf);267} catch (UnknownHostException ukhEx) {268ukhEx.printStackTrace();269testWithNetIf = true;270useMockInet6Address = true;271}272} else {273System.err274.println("\n testSerializedE1000gInet6Address: using index \n");275try {276expectedInet6Address = Inet6Address.getByAddress(277E1000G0HOSTNAME, E1000G0IPV6ADDRESS, SCOPE_ID_ZERO);278} catch (UnknownHostException ukhEx1) {279ukhEx1.printStackTrace();280useMockInet6Address = true;281}282testWithNetIf = false;283}284285byte[] serializedAddress = SerialData_ifname_e1000g0;286287// displayExpectedInet6Address(expectedInet6Address);288289try (ByteArrayInputStream bis = new ByteArrayInputStream(290serializedAddress);291ObjectInputStream oin = new ObjectInputStream(bis)) {292Inet6Address deserializedIPV6Addr = (Inet6Address) oin.readObject();293System.err.println("Deserialized Inet6Address "294+ deserializedIPV6Addr);295296if (!useMockInet6Address) {297assertHostNameEqual(expectedInet6Address.getHostName(),298deserializedIPV6Addr.getHostName());299if (testWithNetIf) {300assertHostAddressEqual(301expectedInet6Address.getHostAddress(),302deserializedIPV6Addr.getHostAddress());303} else {304assertHostAddressEqual(305MockE1000g0Inet6Address.getBareHostAddress(),306deserializedIPV6Addr.getHostAddress());307}308assertAddressEqual(expectedInet6Address.getAddress(),309deserializedIPV6Addr.getAddress());310assertScopeIdEqual(expectedInet6Address.getScopeId(),311deserializedIPV6Addr.getScopeId());312if (testWithNetIf) {313assertNetworkInterfaceEqual(314expectedInet6Address.getScopedInterface(),315deserializedIPV6Addr.getScopedInterface());316} else {317assertNetworkInterfaceEqual(null,318deserializedIPV6Addr.getScopedInterface());319}320} else { // use MockLo0Inet6Address321assertHostNameEqual(MockE1000g0Inet6Address.getHostName(),322deserializedIPV6Addr.getHostName());323if (testWithNetIf) {324assertHostAddressEqual(325MockE1000g0Inet6Address.getHostAddress(),326deserializedIPV6Addr.getHostAddress());327} else {328assertHostAddressEqual(329MockE1000g0Inet6Address.getHostAddressWithIndex(),330deserializedIPV6Addr.getHostAddress());331}332assertAddressEqual(MockE1000g0Inet6Address.getAddress(),333deserializedIPV6Addr.getAddress());334if (testWithNetIf) {335assertScopeIdEqual(MockE1000g0Inet6Address.getScopeId(),336deserializedIPV6Addr.getScopeId());337} else {338assertScopeIdEqual(MockE1000g0Inet6Address.getScopeZero(),339deserializedIPV6Addr.getScopeId());340}341assertNetworkInterfaceNameEqual(342MockE1000g0Inet6Address.getScopeIfName(),343deserializedIPV6Addr.getScopedInterface());344}345} catch (Exception e) {346System.err.println("Exception caught during deserialization");347failed = true;348e.printStackTrace();349}350}351352static void testSerializedLo0Inet6Address() throws IOException {353System.err.println("\n testSerializedLo0Inet6Address: enter \n");354boolean testWithNetIf = true;355boolean useMockInet6Address = false;356357NetworkInterface testNetIf = NetworkInterface.getByName(NETWORK_IF_LO0);358Inet6Address expectedInet6Address = null;359if (testNetIf != null) {360System.err361.println("\n testSerializedLo0Inet6Address: using netif \n");362try {363expectedInet6Address = Inet6Address.getByAddress(LOCALHOSTNAME,364LOOPBACKIPV6ADDRESS, testNetIf);365} catch (UnknownHostException ukhEx) {366ukhEx.printStackTrace();367testWithNetIf = true;368useMockInet6Address = true;369}370} else {371System.err372.println("\n testSerializedLo0Inet6Address: using index \n");373try {374expectedInet6Address = Inet6Address.getByAddress(LOCALHOSTNAME,375LOOPBACKIPV6ADDRESS, SCOPE_ID_ZERO);376} catch (UnknownHostException ukhEx1) {377ukhEx1.printStackTrace();378useMockInet6Address = true;379}380testWithNetIf = false;381}382383// displayExpectedInet6Address(expectedInet6Address);384385byte[] serializedAddress = SerialData_ifname_lo0;386387try (ByteArrayInputStream bis = new ByteArrayInputStream(388serializedAddress);389ObjectInputStream oin = new ObjectInputStream(bis)) {390Inet6Address deserializedIPV6Addr = (Inet6Address) oin.readObject();391System.err.println("Deserialized Inet6Address "392+ deserializedIPV6Addr);393if (!useMockInet6Address) {394assertHostNameEqual(expectedInet6Address.getHostName(),395deserializedIPV6Addr.getHostName());396if (testWithNetIf) {397assertHostAddressEqual(398expectedInet6Address.getHostAddress(),399deserializedIPV6Addr.getHostAddress());400} else {401assertHostAddressEqual(402MockLo0Inet6Address.getBareHostAddress(),403deserializedIPV6Addr.getHostAddress());404}405assertAddressEqual(expectedInet6Address.getAddress(),406deserializedIPV6Addr.getAddress());407assertScopeIdEqual(expectedInet6Address.getScopeId(),408deserializedIPV6Addr.getScopeId());409if (testWithNetIf) {410assertNetworkInterfaceEqual(411expectedInet6Address.getScopedInterface(),412deserializedIPV6Addr.getScopedInterface());413} else {414assertNetworkInterfaceEqual(null,415deserializedIPV6Addr.getScopedInterface());416}417} else { // use MockLo0Inet6Address418assertHostNameEqual(MockLo0Inet6Address.getHostName(),419deserializedIPV6Addr.getHostName());420if (testWithNetIf) {421assertHostAddressEqual(422MockLo0Inet6Address.getHostAddress(),423deserializedIPV6Addr.getHostAddress());424} else {425assertHostAddressEqual(426MockLo0Inet6Address.getHostAddressWithIndex(),427deserializedIPV6Addr.getHostAddress());428}429assertAddressEqual(MockLo0Inet6Address.getAddress(),430deserializedIPV6Addr.getAddress());431if (testWithNetIf) {432assertScopeIdEqual(MockLo0Inet6Address.getScopeId(),433deserializedIPV6Addr.getScopeId());434} else {435assertScopeIdEqual(MockLo0Inet6Address.getScopeZero(),436deserializedIPV6Addr.getScopeId());437}438assertNetworkInterfaceNameEqual(439MockLo0Inet6Address.getScopeIfName(),440deserializedIPV6Addr.getScopedInterface());441}442} catch (Exception e) {443System.err.println("Exception caught during deserialization");444failed = true;445e.printStackTrace();446}447}448449static List<Inet6Address> getAllInet6Addresses() throws Exception {450// System.err.println("\n getAllInet6Addresses: \n ");451ArrayList<Inet6Address> inet6Addresses = new ArrayList<Inet6Address>();452for (Enumeration<NetworkInterface> e = NetworkInterface453.getNetworkInterfaces(); e.hasMoreElements();) {454NetworkInterface netIF = e.nextElement();455for (Enumeration<InetAddress> iadrs = netIF.getInetAddresses(); iadrs456.hasMoreElements();) {457InetAddress iadr = iadrs.nextElement();458if (iadr instanceof Inet6Address) {459System.err.println("Test NetworkInterface: " + netIF);460Inet6Address i6adr = (Inet6Address) iadr;461System.err.println(" address " + iadr);462System.err.println(" scoped iface: "463+ i6adr.getScopedInterface());464// using this to actually set the hostName for an465// InetAddress466// created through the NetworkInterface467// have found that the fabricated instances has a null468// hostName469System.err.println(" hostName: " + i6adr.getHostName());470inet6Addresses.add(i6adr);471}472}473}474return inet6Addresses;475}476477static void assertHostNameEqual(String expectedHostName,478String deserializedHostName) {479System.err480.println("Inet6AddressSerializationTest.assertHostNameEqual:");481if (expectedHostName == null) {482if (deserializedHostName == null) {483// ok, do nothing.484} else {485System.err.println("Error checking " + " HostName, expected:"486+ expectedHostName + ", got :" + deserializedHostName);487failed = true;488}489} else if (!expectedHostName.equals(deserializedHostName)) {490System.err.println("Error checking "491+ // versionStr +492" HostName, expected:" + expectedHostName + ", got :"493+ deserializedHostName);494failed = true;495} else {496System.err.println("HostName equality "497+ // versionStr +498" HostName, expected:" + expectedHostName + ", got :"499+ deserializedHostName);500}501}502503static void assertHostAddressEqual(String expectedHostAddress,504String deserializedHostAddress) {505System.err506.println("Inet6AddressSerializationTest.assertHostAddressEqual:");507if (expectedHostAddress == null) {508if (deserializedHostAddress == null) {509// ok, do nothing.510} else {511System.err.println("Error checking "512+ " HostAddress, expected: " + expectedHostAddress513+ ", got: " + deserializedHostAddress);514failed = true;515}516} else if (!expectedHostAddress.equals(deserializedHostAddress)) {517System.err.println("Error checking "518+ // versionStr +519" HostAddress, expected: " + expectedHostAddress520+ ", got: " + deserializedHostAddress);521failed = true;522} else {523System.err.println("HostAddress equality "524+ // versionStr +525" HostAddress, expected: " + expectedHostAddress526+ ", got: " + deserializedHostAddress);527}528}529530static void assertAddressEqual(byte[] expectedAddress,531byte[] deserializedAddress) {532System.err.println("Inet6AddressSerializationTest.assertAddressEqual:");533if (expectedAddress == null) {534if (deserializedAddress == null) {535// ok, do nothing.536} else {537System.err.println("Error checking " + " Address, expected:"538+ Arrays.toString(expectedAddress) + ", got: "539+ Arrays.toString(deserializedAddress));540failed = true;541}542} else if (!Arrays.equals(expectedAddress, deserializedAddress)) {543System.err.println("Error checking "544+ // versionStr +545" Address, expected: " + Arrays.toString(expectedAddress)546+ ", got: " + Arrays.toString(deserializedAddress));547failed = true;548} else {549System.err.println("Address equality "550+ // versionStr +551" Address, expected: " + Arrays.toString(expectedAddress)552+ ", got: " + Arrays.toString(deserializedAddress));553}554}555556static void assertScopeIdEqual(int expectedScopeId, int deserializedScopeId) {557System.err.println("Inet6AddressSerializationTest.assertScopeIdEqual:");558if (expectedScopeId != deserializedScopeId) {559System.err.println("Error checking " + " ScopeId, expected:"560+ expectedScopeId + ", got: " + deserializedScopeId);561failed = true;562} else {563System.err.println("ScopeId equality "564+ // versionStr +565" ScopeId, expected: " + expectedScopeId + ", got: "566+ deserializedScopeId);567}568}569570static void assertNetworkInterfaceNameEqual(String expectedNetworkIfName,571NetworkInterface deserializedNetworkInterface) {572573if (deserializedNetworkInterface != null) {574String deserializedNetworkIfName = deserializedNetworkInterface575.getName();576System.err577.println("Inet6AddressSerializationTest.assertHostNameEqual:");578if (expectedNetworkIfName == null) {579if (deserializedNetworkIfName == null) {580// ok, do nothing.581} else {582System.err.println("Error checking "583+ " NetworkIfName, expected: "584+ expectedNetworkIfName + ", got: "585+ deserializedNetworkIfName);586failed = true;587}588} else if (!expectedNetworkIfName.equals(deserializedNetworkIfName)) {589System.err.println("Error checking "590+ " NetworkIfName, expected: " + expectedNetworkIfName591+ ", got: " + deserializedNetworkIfName);592failed = true;593} else {594System.err.println("NetworkIfName equality "595+ " NetworkIfName, expected: " + expectedNetworkIfName596+ ", got: " + deserializedNetworkIfName);597}598} else {599System.err600.println("Warning "601+ " NetworkInterface expected, but is null - ifname not relevant on deserializing host");602}603}604605static void assertNetworkInterfaceEqual(606NetworkInterface expectedNetworkInterface,607NetworkInterface deserializedNetworkInterface) {608System.err609.println("Inet6AddressSerializationTest.assertNetworkInterfaceEqual:");610if (expectedNetworkInterface == null) {611if (deserializedNetworkInterface == null) {612// ok, do nothing.613System.err.println("Network Interface equality "614+ " NetworkInterface, expected:"615+ expectedNetworkInterface + ", got :"616+ deserializedNetworkInterface);617} else {618System.err.println("Error checking "619+ " NetworkInterface, expected:"620+ expectedNetworkInterface + ", got :"621+ deserializedNetworkInterface);622failed = true;623}624} else if (!expectedNetworkInterface625.equals(deserializedNetworkInterface)) {626System.err.println("Error checking "627+ // versionStr +628" NetworkInterface, expected:" + expectedNetworkInterface629+ ", got :" + deserializedNetworkInterface);630failed = true;631} else {632System.err.println("Network Interface equality "633+ " NetworkInterface, expected:" + expectedNetworkInterface634+ ", got :" + deserializedNetworkInterface);635}636}637638static void equal(Object expected, Object got) {639if (expected == null) {640if (got == null) {641// ok, do nothing.642} else {643System.err.println("Error checking "644+ " serial data, expected:" + expected + ", got :"645+ got);646failed = true;647}648} else if (!expected.equals(got)) {649System.err.println("Error checking " + // versionStr +650" serial data, expected:" + expected + ", got :" + got);651failed = true;652}653}654655// Used to generate serialData.656static byte[] generateSerializedInet6AddressData(Inet6Address addr,657PrintStream out, boolean outputToFile) throws IOException {658ByteArrayOutputStream bos = new ByteArrayOutputStream();659try (ObjectOutputStream oos = new ObjectOutputStream(bos)) {660oos.writeObject(addr);661}662663String ifname = getIfName(addr);664byte[] ba = bos.toByteArray();665if (out != null) {666out.format("static final byte[] SerialData" + ifname + " = {\n");667for (int i = 0; i < ba.length; i++) {668out.format(" (byte)0x%02X", ba[i]);669if (i != (ba.length - 1))670out.format(",");671if (((i + 1) % 6) == 0)672out.format("\n");673}674out.format(" };\n \n");675}676if (outputToFile) {677serializeInet6AddressToFile(addr);678}679return ba;680}681682private static String getIfName(Inet6Address inet6Addr) {683String ifname;684if (inet6Addr.getScopedInterface() != null) {685ifname = "_ifname_" + inet6Addr.getScopedInterface().getName();686} else {687ifname = "_ifname_"688+ Integer.valueOf(inet6Addr.getScopeId()).toString();689}690return ifname;691}692693static void generateAllInet6AddressSerializedData() throws IOException {694// System.err.println("generateAllInet6AddressSerializedData: enter ....");695696List<Inet6Address> inet6Addresses;697698try {699inet6Addresses = getAllInet6Addresses();700} catch (Exception e) {701e.printStackTrace();702throw new IOException(e);703}704705for (Inet6Address inet6Address : inet6Addresses) {706generateSerializedInet6AddressData(inet6Address, System.out, true);707}708}709710static void serializeInet6AddressToFile(Inet6Address inet6Addr) {711712// System.err713// .println("serializeInet6AddressToIPV6AddressFile: enter ....");714715FileOutputStream fOut = null;716String inet6AddressOutputFilename = null;717inet6AddressOutputFilename = createOutputFileName(inet6Addr);718try {719fOut = new FileOutputStream(inet6AddressOutputFilename);720} catch (FileNotFoundException fnfEx) {721722fnfEx.printStackTrace();723}724ObjectOutputStream ooStream = null;725try {726if (fOut != null) {727ooStream = new ObjectOutputStream(fOut);728} else {729System.err.println("Problem initilising Object output stream ");730System.exit(-1);731}732733} catch (IOException e) {734e.printStackTrace();735System.exit(-1);736}737738// serialise the last Inet6Address739/*740* System.err741* .println("serializeInet6AddressToIPV6AddressFile scoped iface: \n" +742* inet6Addr.getScopedInterface());743*/744try {745ooStream.writeObject(inet6Addr);746} catch (Exception ex) {747ex.printStackTrace();748System.exit(-1);749}750751try {752ooStream.close();753} catch (IOException e) {754e.printStackTrace();755}756}757758private static String createOutputFileName(Inet6Address inet6Addr) {759String inet6AddressOutputFilename;760if (inet6Addr.getScopedInterface() != null) {761inet6AddressOutputFilename = "IPV6Address_"762+ inet6Addr.getScopedInterface().getName() + ".out";763} else {764inet6AddressOutputFilename = "IPV6Address_"765+ Integer.valueOf(inet6Addr.getScopeId()).toString()766+ ".out";767}768return inet6AddressOutputFilename;769}770771// --- Generated data ---772// JDK7 output java Inet6AddressSerializationTest generate.773774// loopback lo0 interface on Solaris 10775776static final byte[] JDK7Inet6AddressSerialData = { (byte) 0xAC,777(byte) 0xED, (byte) 0x00, (byte) 0x05, (byte) 0x73, (byte) 0x72,778(byte) 0x00, (byte) 0x15, (byte) 0x6A, (byte) 0x61, (byte) 0x76,779(byte) 0x61, (byte) 0x2E, (byte) 0x6E, (byte) 0x65, (byte) 0x74,780(byte) 0x2E, (byte) 0x49, (byte) 0x6E, (byte) 0x65, (byte) 0x74,781(byte) 0x36, (byte) 0x41, (byte) 0x64, (byte) 0x64, (byte) 0x72,782(byte) 0x65, (byte) 0x73, (byte) 0x73, (byte) 0x5F, (byte) 0x7C,783(byte) 0x20, (byte) 0x81, (byte) 0x52, (byte) 0x2C, (byte) 0x80,784(byte) 0x21, (byte) 0x03, (byte) 0x00, (byte) 0x05, (byte) 0x49,785(byte) 0x00, (byte) 0x08, (byte) 0x73, (byte) 0x63, (byte) 0x6F,786(byte) 0x70, (byte) 0x65, (byte) 0x5F, (byte) 0x69, (byte) 0x64,787(byte) 0x5A, (byte) 0x00, (byte) 0x0C, (byte) 0x73, (byte) 0x63,788(byte) 0x6F, (byte) 0x70, (byte) 0x65, (byte) 0x5F, (byte) 0x69,789(byte) 0x64, (byte) 0x5F, (byte) 0x73, (byte) 0x65, (byte) 0x74,790(byte) 0x5A, (byte) 0x00, (byte) 0x10, (byte) 0x73, (byte) 0x63,791(byte) 0x6F, (byte) 0x70, (byte) 0x65, (byte) 0x5F, (byte) 0x69,792(byte) 0x66, (byte) 0x6E, (byte) 0x61, (byte) 0x6D, (byte) 0x65,793(byte) 0x5F, (byte) 0x73, (byte) 0x65, (byte) 0x74, (byte) 0x4C,794(byte) 0x00, (byte) 0x06, (byte) 0x69, (byte) 0x66, (byte) 0x6E,795(byte) 0x61, (byte) 0x6D, (byte) 0x65, (byte) 0x74, (byte) 0x00,796(byte) 0x12, (byte) 0x4C, (byte) 0x6A, (byte) 0x61, (byte) 0x76,797(byte) 0x61, (byte) 0x2F, (byte) 0x6C, (byte) 0x61, (byte) 0x6E,798(byte) 0x67, (byte) 0x2F, (byte) 0x53, (byte) 0x74, (byte) 0x72,799(byte) 0x69, (byte) 0x6E, (byte) 0x67, (byte) 0x3B, (byte) 0x5B,800(byte) 0x00, (byte) 0x09, (byte) 0x69, (byte) 0x70, (byte) 0x61,801(byte) 0x64, (byte) 0x64, (byte) 0x72, (byte) 0x65, (byte) 0x73,802(byte) 0x73, (byte) 0x74, (byte) 0x00, (byte) 0x02, (byte) 0x5B,803(byte) 0x42, (byte) 0x78, (byte) 0x72, (byte) 0x00, (byte) 0x14,804(byte) 0x6A, (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2E,805(byte) 0x6E, (byte) 0x65, (byte) 0x74, (byte) 0x2E, (byte) 0x49,806(byte) 0x6E, (byte) 0x65, (byte) 0x74, (byte) 0x41, (byte) 0x64,807(byte) 0x64, (byte) 0x72, (byte) 0x65, (byte) 0x73, (byte) 0x73,808(byte) 0x2D, (byte) 0x9B, (byte) 0x57, (byte) 0xAF, (byte) 0x9F,809(byte) 0xE3, (byte) 0xEB, (byte) 0xDB, (byte) 0x02, (byte) 0x00,810(byte) 0x03, (byte) 0x49, (byte) 0x00, (byte) 0x07, (byte) 0x61,811(byte) 0x64, (byte) 0x64, (byte) 0x72, (byte) 0x65, (byte) 0x73,812(byte) 0x73, (byte) 0x49, (byte) 0x00, (byte) 0x06, (byte) 0x66,813(byte) 0x61, (byte) 0x6D, (byte) 0x69, (byte) 0x6C, (byte) 0x79,814(byte) 0x4C, (byte) 0x00, (byte) 0x08, (byte) 0x68, (byte) 0x6F,815(byte) 0x73, (byte) 0x74, (byte) 0x4E, (byte) 0x61, (byte) 0x6D,816(byte) 0x65, (byte) 0x71, (byte) 0x00, (byte) 0x7E, (byte) 0x00,817(byte) 0x01, (byte) 0x78, (byte) 0x70, (byte) 0x00, (byte) 0x00,818(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,819(byte) 0x02, (byte) 0x74, (byte) 0x00, (byte) 0x09, (byte) 0x6C,820(byte) 0x6F, (byte) 0x63, (byte) 0x61, (byte) 0x6C, (byte) 0x68,821(byte) 0x6F, (byte) 0x73, (byte) 0x74, (byte) 0x00, (byte) 0x00,822(byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x70,823(byte) 0x75, (byte) 0x72, (byte) 0x00, (byte) 0x02, (byte) 0x5B,824(byte) 0x42, (byte) 0xAC, (byte) 0xF3, (byte) 0x17, (byte) 0xF8,825(byte) 0x06, (byte) 0x08, (byte) 0x54, (byte) 0xE0, (byte) 0x02,826(byte) 0x00, (byte) 0x00, (byte) 0x78, (byte) 0x70, (byte) 0x00,827(byte) 0x00, (byte) 0x00, (byte) 0x10, (byte) 0x00, (byte) 0x00,828(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,829(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,830(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x78 };831832// JDK8 output java Inet6AddressSerializationTest generate.833// loopback lo0 interface on Solaris 10834835static final byte[] JDK8Inet6AddressSerialData = { (byte) 0xAC,836(byte) 0xED, (byte) 0x00, (byte) 0x05, (byte) 0x73, (byte) 0x72,837(byte) 0x00, (byte) 0x15, (byte) 0x6A, (byte) 0x61, (byte) 0x76,838(byte) 0x61, (byte) 0x2E, (byte) 0x6E, (byte) 0x65, (byte) 0x74,839(byte) 0x2E, (byte) 0x49, (byte) 0x6E, (byte) 0x65, (byte) 0x74,840(byte) 0x36, (byte) 0x41, (byte) 0x64, (byte) 0x64, (byte) 0x72,841(byte) 0x65, (byte) 0x73, (byte) 0x73, (byte) 0x5F, (byte) 0x7C,842(byte) 0x20, (byte) 0x81, (byte) 0x52, (byte) 0x2C, (byte) 0x80,843(byte) 0x21, (byte) 0x03, (byte) 0x00, (byte) 0x05, (byte) 0x49,844(byte) 0x00, (byte) 0x08, (byte) 0x73, (byte) 0x63, (byte) 0x6F,845(byte) 0x70, (byte) 0x65, (byte) 0x5F, (byte) 0x69, (byte) 0x64,846(byte) 0x5A, (byte) 0x00, (byte) 0x0C, (byte) 0x73, (byte) 0x63,847(byte) 0x6F, (byte) 0x70, (byte) 0x65, (byte) 0x5F, (byte) 0x69,848(byte) 0x64, (byte) 0x5F, (byte) 0x73, (byte) 0x65, (byte) 0x74,849(byte) 0x5A, (byte) 0x00, (byte) 0x10, (byte) 0x73, (byte) 0x63,850(byte) 0x6F, (byte) 0x70, (byte) 0x65, (byte) 0x5F, (byte) 0x69,851(byte) 0x66, (byte) 0x6E, (byte) 0x61, (byte) 0x6D, (byte) 0x65,852(byte) 0x5F, (byte) 0x73, (byte) 0x65, (byte) 0x74, (byte) 0x4C,853(byte) 0x00, (byte) 0x06, (byte) 0x69, (byte) 0x66, (byte) 0x6E,854(byte) 0x61, (byte) 0x6D, (byte) 0x65, (byte) 0x74, (byte) 0x00,855(byte) 0x12, (byte) 0x4C, (byte) 0x6A, (byte) 0x61, (byte) 0x76,856(byte) 0x61, (byte) 0x2F, (byte) 0x6C, (byte) 0x61, (byte) 0x6E,857(byte) 0x67, (byte) 0x2F, (byte) 0x53, (byte) 0x74, (byte) 0x72,858(byte) 0x69, (byte) 0x6E, (byte) 0x67, (byte) 0x3B, (byte) 0x5B,859(byte) 0x00, (byte) 0x09, (byte) 0x69, (byte) 0x70, (byte) 0x61,860(byte) 0x64, (byte) 0x64, (byte) 0x72, (byte) 0x65, (byte) 0x73,861(byte) 0x73, (byte) 0x74, (byte) 0x00, (byte) 0x02, (byte) 0x5B,862(byte) 0x42, (byte) 0x78, (byte) 0x72, (byte) 0x00, (byte) 0x14,863(byte) 0x6A, (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2E,864(byte) 0x6E, (byte) 0x65, (byte) 0x74, (byte) 0x2E, (byte) 0x49,865(byte) 0x6E, (byte) 0x65, (byte) 0x74, (byte) 0x41, (byte) 0x64,866(byte) 0x64, (byte) 0x72, (byte) 0x65, (byte) 0x73, (byte) 0x73,867(byte) 0x2D, (byte) 0x9B, (byte) 0x57, (byte) 0xAF, (byte) 0x9F,868(byte) 0xE3, (byte) 0xEB, (byte) 0xDB, (byte) 0x02, (byte) 0x00,869(byte) 0x03, (byte) 0x49, (byte) 0x00, (byte) 0x07, (byte) 0x61,870(byte) 0x64, (byte) 0x64, (byte) 0x72, (byte) 0x65, (byte) 0x73,871(byte) 0x73, (byte) 0x49, (byte) 0x00, (byte) 0x06, (byte) 0x66,872(byte) 0x61, (byte) 0x6D, (byte) 0x69, (byte) 0x6C, (byte) 0x79,873(byte) 0x4C, (byte) 0x00, (byte) 0x08, (byte) 0x68, (byte) 0x6F,874(byte) 0x73, (byte) 0x74, (byte) 0x4E, (byte) 0x61, (byte) 0x6D,875(byte) 0x65, (byte) 0x71, (byte) 0x00, (byte) 0x7E, (byte) 0x00,876(byte) 0x01, (byte) 0x78, (byte) 0x70, (byte) 0x00, (byte) 0x00,877(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,878(byte) 0x02, (byte) 0x74, (byte) 0x00, (byte) 0x09, (byte) 0x6C,879(byte) 0x6F, (byte) 0x63, (byte) 0x61, (byte) 0x6C, (byte) 0x68,880(byte) 0x6F, (byte) 0x73, (byte) 0x74, (byte) 0x00, (byte) 0x00,881(byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x70,882(byte) 0x75, (byte) 0x72, (byte) 0x00, (byte) 0x02, (byte) 0x5B,883(byte) 0x42, (byte) 0xAC, (byte) 0xF3, (byte) 0x17, (byte) 0xF8,884(byte) 0x06, (byte) 0x08, (byte) 0x54, (byte) 0xE0, (byte) 0x02,885(byte) 0x00, (byte) 0x00, (byte) 0x78, (byte) 0x70, (byte) 0x00,886(byte) 0x00, (byte) 0x00, (byte) 0x10, (byte) 0x00, (byte) 0x00,887(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,888(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,889(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x78 };890891// java Inet6AddressSerializationTest generateAll produces this inet6address892// serial data893// jdk8 generated serialization of on address fe80:0:0:0:21b:24ff:febd:f29c894// net if e1000g0895896static final byte[] SerialData_ifname_e1000g0 = { (byte) 0xAC, (byte) 0xED,897(byte) 0x00, (byte) 0x05, (byte) 0x73, (byte) 0x72, (byte) 0x00,898(byte) 0x15, (byte) 0x6A, (byte) 0x61, (byte) 0x76, (byte) 0x61,899(byte) 0x2E, (byte) 0x6E, (byte) 0x65, (byte) 0x74, (byte) 0x2E,900(byte) 0x49, (byte) 0x6E, (byte) 0x65, (byte) 0x74, (byte) 0x36,901(byte) 0x41, (byte) 0x64, (byte) 0x64, (byte) 0x72, (byte) 0x65,902(byte) 0x73, (byte) 0x73, (byte) 0x5F, (byte) 0x7C, (byte) 0x20,903(byte) 0x81, (byte) 0x52, (byte) 0x2C, (byte) 0x80, (byte) 0x21,904(byte) 0x03, (byte) 0x00, (byte) 0x05, (byte) 0x49, (byte) 0x00,905(byte) 0x08, (byte) 0x73, (byte) 0x63, (byte) 0x6F, (byte) 0x70,906(byte) 0x65, (byte) 0x5F, (byte) 0x69, (byte) 0x64, (byte) 0x5A,907(byte) 0x00, (byte) 0x0C, (byte) 0x73, (byte) 0x63, (byte) 0x6F,908(byte) 0x70, (byte) 0x65, (byte) 0x5F, (byte) 0x69, (byte) 0x64,909(byte) 0x5F, (byte) 0x73, (byte) 0x65, (byte) 0x74, (byte) 0x5A,910(byte) 0x00, (byte) 0x10, (byte) 0x73, (byte) 0x63, (byte) 0x6F,911(byte) 0x70, (byte) 0x65, (byte) 0x5F, (byte) 0x69, (byte) 0x66,912(byte) 0x6E, (byte) 0x61, (byte) 0x6D, (byte) 0x65, (byte) 0x5F,913(byte) 0x73, (byte) 0x65, (byte) 0x74, (byte) 0x4C, (byte) 0x00,914(byte) 0x06, (byte) 0x69, (byte) 0x66, (byte) 0x6E, (byte) 0x61,915(byte) 0x6D, (byte) 0x65, (byte) 0x74, (byte) 0x00, (byte) 0x12,916(byte) 0x4C, (byte) 0x6A, (byte) 0x61, (byte) 0x76, (byte) 0x61,917(byte) 0x2F, (byte) 0x6C, (byte) 0x61, (byte) 0x6E, (byte) 0x67,918(byte) 0x2F, (byte) 0x53, (byte) 0x74, (byte) 0x72, (byte) 0x69,919(byte) 0x6E, (byte) 0x67, (byte) 0x3B, (byte) 0x5B, (byte) 0x00,920(byte) 0x09, (byte) 0x69, (byte) 0x70, (byte) 0x61, (byte) 0x64,921(byte) 0x64, (byte) 0x72, (byte) 0x65, (byte) 0x73, (byte) 0x73,922(byte) 0x74, (byte) 0x00, (byte) 0x02, (byte) 0x5B, (byte) 0x42,923(byte) 0x78, (byte) 0x72, (byte) 0x00, (byte) 0x14, (byte) 0x6A,924(byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2E, (byte) 0x6E,925(byte) 0x65, (byte) 0x74, (byte) 0x2E, (byte) 0x49, (byte) 0x6E,926(byte) 0x65, (byte) 0x74, (byte) 0x41, (byte) 0x64, (byte) 0x64,927(byte) 0x72, (byte) 0x65, (byte) 0x73, (byte) 0x73, (byte) 0x2D,928(byte) 0x9B, (byte) 0x57, (byte) 0xAF, (byte) 0x9F, (byte) 0xE3,929(byte) 0xEB, (byte) 0xDB, (byte) 0x02, (byte) 0x00, (byte) 0x03,930(byte) 0x49, (byte) 0x00, (byte) 0x07, (byte) 0x61, (byte) 0x64,931(byte) 0x64, (byte) 0x72, (byte) 0x65, (byte) 0x73, (byte) 0x73,932(byte) 0x49, (byte) 0x00, (byte) 0x06, (byte) 0x66, (byte) 0x61,933(byte) 0x6D, (byte) 0x69, (byte) 0x6C, (byte) 0x79, (byte) 0x4C,934(byte) 0x00, (byte) 0x08, (byte) 0x68, (byte) 0x6F, (byte) 0x73,935(byte) 0x74, (byte) 0x4E, (byte) 0x61, (byte) 0x6D, (byte) 0x65,936(byte) 0x71, (byte) 0x00, (byte) 0x7E, (byte) 0x00, (byte) 0x01,937(byte) 0x78, (byte) 0x70, (byte) 0x00, (byte) 0x00, (byte) 0x00,938(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x02,939(byte) 0x74, (byte) 0x00, (byte) 0x25, (byte) 0x66, (byte) 0x65,940(byte) 0x38, (byte) 0x30, (byte) 0x3A, (byte) 0x30, (byte) 0x3A,941(byte) 0x30, (byte) 0x3A, (byte) 0x30, (byte) 0x3A, (byte) 0x32,942(byte) 0x31, (byte) 0x62, (byte) 0x3A, (byte) 0x32, (byte) 0x34,943(byte) 0x66, (byte) 0x66, (byte) 0x3A, (byte) 0x66, (byte) 0x65,944(byte) 0x62, (byte) 0x64, (byte) 0x3A, (byte) 0x66, (byte) 0x32,945(byte) 0x39, (byte) 0x63, (byte) 0x25, (byte) 0x65, (byte) 0x31,946(byte) 0x30, (byte) 0x30, (byte) 0x30, (byte) 0x67, (byte) 0x30,947(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x02, (byte) 0x01,948(byte) 0x01, (byte) 0x74, (byte) 0x00, (byte) 0x07, (byte) 0x65,949(byte) 0x31, (byte) 0x30, (byte) 0x30, (byte) 0x30, (byte) 0x67,950(byte) 0x30, (byte) 0x75, (byte) 0x72, (byte) 0x00, (byte) 0x02,951(byte) 0x5B, (byte) 0x42, (byte) 0xAC, (byte) 0xF3, (byte) 0x17,952(byte) 0xF8, (byte) 0x06, (byte) 0x08, (byte) 0x54, (byte) 0xE0,953(byte) 0x02, (byte) 0x00, (byte) 0x00, (byte) 0x78, (byte) 0x70,954(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x10, (byte) 0xFE,955(byte) 0x80, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,956(byte) 0x00, (byte) 0x00, (byte) 0x02, (byte) 0x1B, (byte) 0x24,957(byte) 0xFF, (byte) 0xFE, (byte) 0xBD, (byte) 0xF2, (byte) 0x9C,958(byte) 0x78 };959960// jdk8 generated serialization of address 0::1 on net if lo0 hostname961// localhost scope_id 1962963static final byte[] SerialData_ifname_lo0 = { (byte) 0xAC, (byte) 0xED,964(byte) 0x00, (byte) 0x05, (byte) 0x73, (byte) 0x72, (byte) 0x00,965(byte) 0x15, (byte) 0x6A, (byte) 0x61, (byte) 0x76, (byte) 0x61,966(byte) 0x2E, (byte) 0x6E, (byte) 0x65, (byte) 0x74, (byte) 0x2E,967(byte) 0x49, (byte) 0x6E, (byte) 0x65, (byte) 0x74, (byte) 0x36,968(byte) 0x41, (byte) 0x64, (byte) 0x64, (byte) 0x72, (byte) 0x65,969(byte) 0x73, (byte) 0x73, (byte) 0x5F, (byte) 0x7C, (byte) 0x20,970(byte) 0x81, (byte) 0x52, (byte) 0x2C, (byte) 0x80, (byte) 0x21,971(byte) 0x03, (byte) 0x00, (byte) 0x05, (byte) 0x49, (byte) 0x00,972(byte) 0x08, (byte) 0x73, (byte) 0x63, (byte) 0x6F, (byte) 0x70,973(byte) 0x65, (byte) 0x5F, (byte) 0x69, (byte) 0x64, (byte) 0x5A,974(byte) 0x00, (byte) 0x0C, (byte) 0x73, (byte) 0x63, (byte) 0x6F,975(byte) 0x70, (byte) 0x65, (byte) 0x5F, (byte) 0x69, (byte) 0x64,976(byte) 0x5F, (byte) 0x73, (byte) 0x65, (byte) 0x74, (byte) 0x5A,977(byte) 0x00, (byte) 0x10, (byte) 0x73, (byte) 0x63, (byte) 0x6F,978(byte) 0x70, (byte) 0x65, (byte) 0x5F, (byte) 0x69, (byte) 0x66,979(byte) 0x6E, (byte) 0x61, (byte) 0x6D, (byte) 0x65, (byte) 0x5F,980(byte) 0x73, (byte) 0x65, (byte) 0x74, (byte) 0x4C, (byte) 0x00,981(byte) 0x06, (byte) 0x69, (byte) 0x66, (byte) 0x6E, (byte) 0x61,982(byte) 0x6D, (byte) 0x65, (byte) 0x74, (byte) 0x00, (byte) 0x12,983(byte) 0x4C, (byte) 0x6A, (byte) 0x61, (byte) 0x76, (byte) 0x61,984(byte) 0x2F, (byte) 0x6C, (byte) 0x61, (byte) 0x6E, (byte) 0x67,985(byte) 0x2F, (byte) 0x53, (byte) 0x74, (byte) 0x72, (byte) 0x69,986(byte) 0x6E, (byte) 0x67, (byte) 0x3B, (byte) 0x5B, (byte) 0x00,987(byte) 0x09, (byte) 0x69, (byte) 0x70, (byte) 0x61, (byte) 0x64,988(byte) 0x64, (byte) 0x72, (byte) 0x65, (byte) 0x73, (byte) 0x73,989(byte) 0x74, (byte) 0x00, (byte) 0x02, (byte) 0x5B, (byte) 0x42,990(byte) 0x78, (byte) 0x72, (byte) 0x00, (byte) 0x14, (byte) 0x6A,991(byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2E, (byte) 0x6E,992(byte) 0x65, (byte) 0x74, (byte) 0x2E, (byte) 0x49, (byte) 0x6E,993(byte) 0x65, (byte) 0x74, (byte) 0x41, (byte) 0x64, (byte) 0x64,994(byte) 0x72, (byte) 0x65, (byte) 0x73, (byte) 0x73, (byte) 0x2D,995(byte) 0x9B, (byte) 0x57, (byte) 0xAF, (byte) 0x9F, (byte) 0xE3,996(byte) 0xEB, (byte) 0xDB, (byte) 0x02, (byte) 0x00, (byte) 0x03,997(byte) 0x49, (byte) 0x00, (byte) 0x07, (byte) 0x61, (byte) 0x64,998(byte) 0x64, (byte) 0x72, (byte) 0x65, (byte) 0x73, (byte) 0x73,999(byte) 0x49, (byte) 0x00, (byte) 0x06, (byte) 0x66, (byte) 0x61,1000(byte) 0x6D, (byte) 0x69, (byte) 0x6C, (byte) 0x79, (byte) 0x4C,1001(byte) 0x00, (byte) 0x08, (byte) 0x68, (byte) 0x6F, (byte) 0x73,1002(byte) 0x74, (byte) 0x4E, (byte) 0x61, (byte) 0x6D, (byte) 0x65,1003(byte) 0x71, (byte) 0x00, (byte) 0x7E, (byte) 0x00, (byte) 0x01,1004(byte) 0x78, (byte) 0x70, (byte) 0x00, (byte) 0x00, (byte) 0x00,1005(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x02,1006(byte) 0x74, (byte) 0x00, (byte) 0x09, (byte) 0x6C, (byte) 0x6F,1007(byte) 0x63, (byte) 0x61, (byte) 0x6C, (byte) 0x68, (byte) 0x6F,1008(byte) 0x73, (byte) 0x74, (byte) 0x00, (byte) 0x00, (byte) 0x00,1009(byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x74, (byte) 0x00,1010(byte) 0x03, (byte) 0x6C, (byte) 0x6F, (byte) 0x30, (byte) 0x75,1011(byte) 0x72, (byte) 0x00, (byte) 0x02, (byte) 0x5B, (byte) 0x42,1012(byte) 0xAC, (byte) 0xF3, (byte) 0x17, (byte) 0xF8, (byte) 0x06,1013(byte) 0x08, (byte) 0x54, (byte) 0xE0, (byte) 0x02, (byte) 0x00,1014(byte) 0x00, (byte) 0x78, (byte) 0x70, (byte) 0x00, (byte) 0x00,1015(byte) 0x00, (byte) 0x10, (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) 0x00,1018(byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x78 };10191020}10211022class MockLo0Inet6Address {10231024private static final byte[] LOOPBACKIPV6ADDRESS = { (byte) 0x00,1025(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,1026(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,1027(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01 };10281029private static final String LOCALHOSTNAME = "localhost";10301031private static final String LO0HOSTADDRESS = "0:0:0:0:0:0:0:1%lo0";10321033private static final String BARE_LO0HOSTADDRESS = "0:0:0:0:0:0:0:1";10341035private static final String LO0HOSTADDRESS_WITHINDEX = "0:0:0:0:0:0:0:1%1";10361037private static final int SCOPE_ID_LO0 = 1;10381039private static final int SCOPE_ID_ZERO = 0;10401041public static final String NETWORK_IF_LO0 = "lo0";10421043static String getHostName() {1044return LOCALHOSTNAME;1045}10461047static String getHostAddress() {1048return LO0HOSTADDRESS;1049}10501051static String getBareHostAddress() {1052return BARE_LO0HOSTADDRESS;1053}10541055static String getHostAddressWithIndex() {1056return LO0HOSTADDRESS_WITHINDEX;1057}10581059static byte[] getAddress() {1060return LOOPBACKIPV6ADDRESS;1061}10621063static int getScopeId() {1064return SCOPE_ID_LO0;1065}10661067static int getScopeZero() {1068return SCOPE_ID_ZERO;1069}10701071static String getScopeIfName() {1072return NETWORK_IF_LO0;1073}10741075}10761077class MockE1000g0Inet6Address {10781079// fe80::21b:24ff:febd:f29c1080private static final byte[] E1000G0IPV6ADDRESS = { (byte) 0xfe,1081(byte) 0x80, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,1082(byte) 0x00, (byte) 0x00, (byte) 0x02, (byte) 0x1b, (byte) 0x24,1083(byte) 0xff, (byte) 0xfe, (byte) 0xbd, (byte) 0xf2, (byte) 0x9c };10841085private static final String E1000G0HOSTNAME = "fe80:0:0:0:21b:24ff:febd:f29c%e1000g0";10861087private static final String BARE_E1000G0HOSTADDRESS = "fe80:0:0:0:21b:24ff:febd:f29c";10881089private static final String E1000G0HOSTADDRESS_WITHINDEX = "fe80:0:0:0:21b:24ff:febd:f29c%2";10901091private static final String E1000G0HOSTADDRESS = "fe80:0:0:0:21b:24ff:febd:f29c%e1000g0";10921093private static final String NETWORK_IF_E1000G0 = "e1000g0";10941095private static final int SCOPE_ID_E1000G0 = 2;10961097private static final int SCOPE_ID_ZERO = 0;10981099static String getHostName() {1100return E1000G0HOSTNAME;1101}11021103static String getHostAddress() {1104return E1000G0HOSTADDRESS;1105}11061107static String getHostAddressWithIndex() {1108return E1000G0HOSTADDRESS_WITHINDEX;1109}11101111static String getBareHostAddress() {1112return BARE_E1000G0HOSTADDRESS;1113}11141115static byte[] getAddress() {1116return E1000G0IPV6ADDRESS;1117}11181119static int getScopeId() {1120return SCOPE_ID_E1000G0;1121}11221123static int getScopeZero() {1124return SCOPE_ID_ZERO;1125}11261127static String getScopeIfName() {1128return NETWORK_IF_E1000G0;1129}11301131}113211331134