Example usage for com.google.common.net InetAddresses getEmbeddedIPv4ClientAddress

List of usage examples for com.google.common.net InetAddresses getEmbeddedIPv4ClientAddress

Introduction

In this page you can find the example usage for com.google.common.net InetAddresses getEmbeddedIPv4ClientAddress.

Prototype

public static Inet4Address getEmbeddedIPv4ClientAddress(Inet6Address ip) 

Source Link

Document

Examines the Inet6Address to extract the embedded IPv4 client address if the InetAddress is an IPv6 address of one of the specified address types that contain an embedded IPv4 address.

Usage

From source file:org.calrissian.mango.net.MoreInetAddresses.java

/**
 * Examines the Inet6Address to extract the embedded IPv4 client address
 * if the InetAddress is an IPv6 address of one of the specified address
 * types that contain an embedded IPv4 address.
 *
 * <p>NOTE: This simply extends the {@code InetAddresses.getEmbeddedIPv4ClientAddress} functionality
 * to support "IPv4 mapped" addresses./*from   w w w .  j  av a2  s. c  o m*/
 *
 * @param ip {@link Inet6Address} to be examined for embedded IPv4 client address
 * @return {@link Inet4Address} of embedded IPv4 client address
 * @throws IllegalArgumentException if the argument does not have a valid embedded IPv4 address
 */
public static Inet4Address getEmbeddedIPv4ClientAddress(Inet6Address ip) {
    if (isMappedIPv4Address(ip))
        return getMappedIPv4Address(ip);

    return InetAddresses.getEmbeddedIPv4ClientAddress(ip);
}