Android examples for Network:IP Address
Returns true if this address is an IPv6 address, is globally routeable
/***************************************************************************** * Project: Android IPv6Config//www . j a v a 2 s . c o m * Description: Android application to change IPv6 kernel configuration * Author: Ren? Mayrhofer * Copyright: Ren? Mayrhofer, 2011-2014 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 * as published by the Free Software Foundation. *****************************************************************************/ //package com.java2s; import java.net.Inet6Address; import java.net.InetAddress; public class Main { /** Returns true if this address is an IPv6 address, is globally routeable (i.e. * it is not a link- or site-local address), and has been derived from a MAC * address using the EUI scheme. */ public static boolean isIPv6GlobalMacDerivedAddress(InetAddress address) { if (address == null || !(address instanceof Inet6Address)) // only check valid IPv6 addresses return false; Inet6Address addr6 = (Inet6Address) address; if (addr6.isLinkLocalAddress()) // if it's link-local, it may be MAC-derived, but not privacy sensitive return false; byte[] addrByte = addr6.getAddress(); // MAC-derivation adds "FFFE" in the middle of the 48 bits MAC return addrByte[11] == (byte) 0xff && addrByte[12] == (byte) 0xfe; } }