Search in sources :

Example 11 with IPv6Address

use of com.googlecode.ipv6.IPv6Address in project cloudstack by apache.

the class NetUtils method getNextIp6InRange.

public static String getNextIp6InRange(final String currentIp, final String ipRange) {
    final String[] ips = ipRange.split("-");
    final String startIp = ips[0];
    String endIp = null;
    if (ips.length > 1) {
        endIp = ips[1];
    }
    final IPv6Address start = IPv6Address.fromString(startIp);
    final IPv6Address end = IPv6Address.fromString(endIp);
    final IPv6Address current = IPv6Address.fromString(currentIp);
    IPv6Address result = null;
    if (current.equals(end)) {
        result = start;
    } else {
        result = current.add(1);
    }
    String resultIp = null;
    if (result != null) {
        resultIp = result.toString();
    }
    return resultIp;
}
Also used : IPv6Address(com.googlecode.ipv6.IPv6Address)

Aggregations

IPv6Address (com.googlecode.ipv6.IPv6Address)11 IPv6AddressRange (com.googlecode.ipv6.IPv6AddressRange)5 IPv6Network (com.googlecode.ipv6.IPv6Network)2 HashSet (java.util.HashSet)2 Iterator (java.util.Iterator)2 Set (java.util.Set)2 StringTokenizer (java.util.StringTokenizer)2 DataCenter (com.cloud.dc.DataCenter)1 VlanVO (com.cloud.dc.VlanVO)1 InsufficientAddressCapacityException (com.cloud.exception.InsufficientAddressCapacityException)1 PublicIp (com.cloud.network.addr.PublicIp)1 IPAddressVO (com.cloud.network.dao.IPAddressVO)1 DB (com.cloud.utils.db.DB)1 TransactionStatus (com.cloud.utils.db.TransactionStatus)1 Nic (com.cloud.vm.Nic)1 EntitlementException (com.sun.identity.entitlement.EntitlementException)1 PolicyException (com.sun.identity.policy.PolicyException)1 BigInteger (java.math.BigInteger)1 InetAddress (java.net.InetAddress)1 UnknownHostException (java.net.UnknownHostException)1