2362N/A * Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 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 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 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 * 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. 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 0N/A * This class represents an Internet Protocol version 4 (IPv4) address. 0N/A * <i>RFC 790: Assigned Numbers</i></a>, 0N/A * <i>RFC 1918: Address Allocation for Private Internets</i></a>, 0N/A * Administratively Scoped IP Multicast</i></a> 0N/A * <h4> <A NAME="format">Textual representation of IP addresses</a> </h4> 0N/A * Textual representation of IPv4 address used as input to methods 0N/A * takes one of the following forms: 0N/A * <blockquote><table cellpadding=0 cellspacing=0 summary="layout"> 0N/A * <tr><td><tt>d.d.d.d</tt></td></tr> 0N/A * <tr><td><tt>d.d.d</tt></td></tr> 0N/A * <tr><td><tt>d.d</tt></td></tr> 0N/A * <tr><td><tt>d</tt></td></tr> 0N/A * </table></blockquote> 0N/A * <p> When four parts are specified, each is interpreted as a byte of 0N/A * data and assigned, from left to right, to the four bytes of an IPv4 0N/A * <p> When a three part address is specified, the last part is 0N/A * interpreted as a 16-bit quantity and placed in the right most two 0N/A * bytes of the network address. This makes the three part address 0N/A * format convenient for specifying Class B net- work addresses as 0N/A * <p> When a two part address is supplied, the last part is 0N/A * interpreted as a 24-bit quantity and placed in the right most three 0N/A * bytes of the network address. This makes the two part address 0N/A * format convenient for specifying Class A network addresses as 0N/A * <p> When only one part is given, the value is stored directly in 0N/A * the network address without any byte rearrangement. 0N/A * <p> For methods that return a textual representation as output 0N/A * value, the first form, i.e. a dotted-quad string, is used. 0N/A * <h4> The Scope of a Multicast Address </h4> 0N/A * Historically the IPv4 TTL field in the IP header has doubled as a 0N/A * multicast scope field: a TTL of 0 means node-local, 1 means 0N/A * link-local, up through 32 means site-local, up through 64 means 0N/A * region-local, up through 128 means continent-local, and up through 0N/A * 255 are global. However, the administrative scoping is preferred. 0N/A * <i>RFC 2365: Administratively Scoped IP Multicast</i></a> 0N/A /** use serialVersionUID from InetAddress, but Inet4Address instance 0N/A * is always replaced by an InetAddress instance before being 0N/A * Perform initializations. 0N/A * Replaces the object to be serialized with an InetAddress object. 0N/A * @return the alternate object to be serialized. 0N/A * @throws ObjectStreamException if a new object replacing this 0N/A * object could not be created 0N/A // will replace the to be serialized 'this' object 0N/A * Prior to 1.4 an InetAddress was created with a family 0N/A * based on the platform AF_INET value (usually 2). 0N/A * For compatibility reasons we must therefore write the 0N/A * the InetAddress with this family. 0N/A * Utility routine to check if the InetAddress is an 0N/A * IP multicast address. IP multicast address is a Class D 0N/A * address i.e first four bits of the address are 1110. 0N/A * @return a <code>boolean</code> indicating if the InetAddress is 0N/A * an IP multicast address 0N/A * Utility routine to check if the InetAddress in a wildcard address. 0N/A * @return a <code>boolean</code> indicating if the Inetaddress is 0N/A * a wildcard address. 0N/A * Utility routine to check if the InetAddress is a loopback address. 0N/A * @return a <code>boolean</code> indicating if the InetAddress is 0N/A * a loopback address; or false otherwise. 0N/A private static final int loopback =
2130706433;
/* 127.0.0.1 */ 0N/A * Utility routine to check if the InetAddress is an link local address. 0N/A * @return a <code>boolean</code> indicating if the InetAddress is 0N/A * a link local address; or false if address is not a link local unicast address. 0N/A // link-local unicast in IPv4 (169.254.0.0/16) 0N/A // defined in "Documenting Special Use IPv4 Address Blocks 0N/A // that have been Registered with IANA" by Bill Manning 0N/A * Utility routine to check if the InetAddress is a site local address. 0N/A * @return a <code>boolean</code> indicating if the InetAddress is 0N/A * a site local address; or false if address is not a site local unicast address. 0N/A // refer to RFC 1918 0N/A // 192.168/16 prefix 0N/A * Utility routine to check if the multicast address has global scope. 0N/A * @return a <code>boolean</code> indicating if the address has 0N/A * is a multicast address of global scope, false if it is not 0N/A * of global scope or it is not a multicast address 0N/A // 224.0.1.0 to 238.255.255.255 0N/A * Utility routine to check if the multicast address has node scope. 0N/A * @return a <code>boolean</code> indicating if the address has 0N/A * is a multicast address of node-local scope, false if it is not 0N/A * of node-local scope or it is not a multicast address 0N/A * Utility routine to check if the multicast address has link scope. 0N/A * @return a <code>boolean</code> indicating if the address has 0N/A * is a multicast address of link-local scope, false if it is not 0N/A * of link-local scope or it is not a multicast address 0N/A // 224.0.0/24 prefix and ttl == 1 0N/A * Utility routine to check if the multicast address has site scope. 0N/A * @return a <code>boolean</code> indicating if the address has 0N/A * is a multicast address of site-local scope, false if it is not 0N/A * of site-local scope or it is not a multicast address 0N/A // 239.255/16 prefix or ttl < 32 0N/A * Utility routine to check if the multicast address has organization scope. 0N/A * @return a <code>boolean</code> indicating if the address has 0N/A * is a multicast address of organization-local scope, 0N/A * false if it is not of organization-local scope 0N/A * or it is not a multicast address 0N/A // 239.192 - 239.195 0N/A * Returns the raw IP address of this <code>InetAddress</code> 0N/A * object. The result is in network byte order: the highest order 0N/A * byte of the address is in <code>getAddress()[0]</code>. 0N/A * @return the raw IP address of this object. 0N/A * Returns the IP address string in textual presentation form. 0N/A * @return the raw IP address in a string format. 0N/A * Returns a hashcode for this IP address. 0N/A * @return a hash code value for this IP address. 0N/A * Compares this object against the specified object. 0N/A * The result is <code>true</code> if and only if the argument is 0N/A * not <code>null</code> and it represents the same IP address as 0N/A * Two instances of <code>InetAddress</code> represent the same IP 0N/A * address if the length of the byte arrays returned by 0N/A * <code>getAddress</code> is the same for both, and each of the 0N/A * array components is the same for the byte arrays. 0N/A * @param obj the object to compare against. 0N/A * @return <code>true</code> if the objects are the same; 0N/A * <code>false</code> otherwise. 0N/A * @see java.net.InetAddress#getAddress() 0N/A * Converts IPv4 binary address into a string suitable for presentation. 0N/A * @param src a byte array representing an IPv4 numeric address 0N/A * @return a String representing the IPv4 address in 0N/A * textual representation format 0N/A return (
src[
0] &
0xff) +
"." + (
src[
1] &
0xff) +
"." + (
src[
2] &
0xff) +
"." + (
src[
3] &
0xff);
0N/A * Perform class load-time initializations.