2362N/A * Copyright (c) 2004, 2005, 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 * Converts IPv4 address in its textual presentation form 0N/A * into its numeric binary form. 0N/A * @param src a String representing an IPv4 address in standard format 0N/A * @return a byte array representing the IPv4 numeric address 0N/A * When only one part is given, the value is stored directly in 0N/A * the network address without any byte rearrangement. 0N/A res[
1] = (
byte) (((
val &
0xffffff) >>
16) &
0xff);
0N/A res[
2] = (
byte) (((
val &
0xffff) >>
8) &
0xff);
0N/A * When a two part address is supplied, the last part is 0N/A * interpreted as a 24-bit quantity and placed in the right 0N/A * most three bytes of the network address. This makes the 0N/A * two part address format convenient for specifying Class A 0N/A * network addresses as net.host. 0N/A res[
2] = (
byte) (((
val &
0xffff) >>
8) &
0xff);
0N/A * When a three part address is specified, the last part is 0N/A * interpreted as a 16-bit quantity and placed in the right 0N/A * most two bytes of the network address. This makes the 0N/A * three part address format convenient for specifying 0N/A * Class B net- work addresses as 128.net.host. 0N/A for (
int i =
0; i <
2; i++) {
0N/A * When four parts are specified, each is interpreted as a 0N/A * byte of data and assigned, from left to right, to the 0N/A * four bytes of an IPv4 address. 0N/A for (
int i =
0; i <
4; i++) {
0N/A * Convert IPv6 presentation level address to network order binary form. 0N/A * Converted from C code from Solaris 8 (inet_pton) 0N/A * Any component of the string following a per-cent % is ignored. 0N/A * @param src a String representing an IPv6 address in textual format 0N/A * @return a byte array representing the IPv6 numeric address 0N/A // Shortest valid string is "::", hence at least 2 chars 0N/A /* Leading :: requires some special handling. */ 0N/A /* check this IPv4 address has 3 dots, ie. A.B.C.D */ 0N/A break;
/* '\0' was seen by inet_pton4(). */ 0N/A for (i =
1; i <= n; i++) {
0N/A * @param src a String representing an IPv4 address in textual format 0N/A * @return a boolean indicating whether src is an IPv4 literal address 0N/A * @param src a String representing an IPv6 address in textual format 0N/A * @return a boolean indicating whether src is an IPv6 literal address 0N/A * Convert IPv4-Mapped address to IPv4 address. Both input and 0N/A * returned value are in network order binary form. 0N/A * @param src a String representing an IPv4-Mapped address in textual format 0N/A * @return a byte array representing the IPv4 numeric address 0N/A * Utility routine to check if the InetAddress is an 0N/A * IPv4 mapped IPv6 address. 0N/A * @return a <code>boolean</code> indicating if the InetAddress is 0N/A * an IPv4 mapped IPv6 address; or false if address is IPv4 address.