/** * When using StateLess Address AutoConfiguration (SLAAC) for IPv6 the addresses * choosen by hosts in a network are based on the 48-bit MAC address and this is expanded to 64-bits * with EUI-64 * FFFE is inserted into the address and these can be identified * * By converting the IPv6 Address to a byte array we can check the 11th and 12th byte to see if the * address is EUI064. * * See RFC4291 for more information * * @param address IPv6Address to be checked * @return True if Address is EUI-64 IPv6 */ public static boolean isIPv6EUI64(final IPv6Address address) { byte[] bytes = address.toByteArray(); return (bytes[11] == IPV6_EUI64_11TH_BYTE && bytes[12] == IPV6_EUI64_12TH_BYTE); }
/** * @return {@link java.math.BigInteger} representation. The magnitude of the {@link java.math.BigInteger} represents the IPv6 address * value. Or in other words, the {@link java.math.BigInteger} with value N defines the Nth possible IPv6 address. */ public BigInteger toBigInteger() { return new BigInteger(1, toByteArray()); }
/** * @return {@link java.math.BigInteger} representation. The magnitude of the {@link java.math.BigInteger} represents the IPv6 address * value. Or in other words, the {@link java.math.BigInteger} with value N defines the Nth possible IPv6 address. */ public BigInteger toBigInteger() { return new BigInteger(1, toByteArray()); }
/** * @return number of addresses in the range */ public BigInteger size() { BigInteger firstAsBigInteger = new BigInteger(1, first.toByteArray()); BigInteger lastAsBigInteger = new BigInteger(1, last.toByteArray()); // note that first and last are included in the range. return lastAsBigInteger.subtract(firstAsBigInteger).add(BigInteger.ONE); }
/** * @return number of addresses in the range */ public BigInteger size() { BigInteger firstAsBigInteger = new BigInteger(1, first.toByteArray()); BigInteger lastAsBigInteger = new BigInteger(1, last.toByteArray()); // note that first and last are included in the range. return lastAsBigInteger.subtract(firstAsBigInteger).add(BigInteger.ONE); }