Package com.googlecode.ipv6

Examples of com.googlecode.ipv6.IPv6Network


  // Can cover 127 bits
  public static String getIp6FromRange(String ip6Range) {
      String[] ips = ip6Range.split("-");
      String startIp = ips[0];
      IPv6Address start = IPv6Address.fromString(startIp);
      BigInteger gap = countIp6InRange(ip6Range);
      BigInteger next = new BigInteger(gap.bitLength(), _rand);
      while (next.compareTo(gap) >= 0) {
        next = new BigInteger(gap.bitLength(), _rand);
      }
      BigInteger startInt = convertIPv6AddressToBigInteger(start);
      BigInteger resultInt = startInt.add(next);
      InetAddress resultAddr;
    try {
      resultAddr = InetAddress.getByAddress(resultInt.toByteArray());
    } catch (UnknownHostException e) {
      return null;
    }
      IPv6Address ip = IPv6Address.fromInetAddress(resultAddr);
      return ip.toString();
  }
View Full Code Here


      String startIp = ips[0];
      String endIp = ips[0];
      if (ips.length > 1) {
        endIp = ips[1];
      }
      IPv6Address start, end;
      try {
        start = IPv6Address.fromString(startIp);
        end = IPv6Address.fromString(endIp);
    } catch (IllegalArgumentException ex) {
      return null;
View Full Code Here

      String startIp = ips[0];
      String endIp = null;
      if (ips.length > 1) {
        endIp = ips[1];
      }
      IPv6Address start = IPv6Address.fromString(startIp);
      IPv6Address end = IPv6Address.fromString(endIp);
      IPv6Address ip = IPv6Address.fromString(ip6);
      if (start.compareTo(ip) <= 0 && end.compareTo(ip) >= 0) {
        return true;
      }
    return false;
  }
View Full Code Here

    try {
      network = IPv6Network.fromString(ip6Cidr);
    } catch (IllegalArgumentException ex) {
      return false;
    }
      IPv6Address ip = IPv6Address.fromString(ip6);
    return network.contains(ip);
  }
View Full Code Here

      String startIp1 = ips[0];
      String endIp1 = null;
      if (ips.length > 1) {
        endIp1 = ips[1];
      }
      IPv6Address start1 = IPv6Address.fromString(startIp1);
      IPv6Address end1 = IPv6Address.fromString(endIp1);
      IPv6AddressRange range1 = IPv6AddressRange.fromFirstAndLast(start1, end1);
    ips = ipRange2.split("-");
      String startIp2 = ips[0];
      String endIp2 = null;
      if (ips.length > 1) {
        endIp2 = ips[1];
      }
      IPv6Address start2 = IPv6Address.fromString(startIp2);
      IPv6Address end2 = IPv6Address.fromString(endIp2);
      IPv6AddressRange range2 = IPv6AddressRange.fromFirstAndLast(start2, end2);
      return range1.overlaps(range2);
  }
View Full Code Here

      String startIp = ips[0];
      String endIp = null;
      if (ips.length > 1) {
        endIp = ips[1];
      }
      IPv6Address start = IPv6Address.fromString(startIp);
      IPv6Address end = IPv6Address.fromString(endIp);
      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;
  }
View Full Code Here

      if (ips.length > 1) {
        endIp1 = ips[1];
      }
      IPv6Address start1 = IPv6Address.fromString(startIp1);
      IPv6Address end1 = IPv6Address.fromString(endIp1);
      IPv6AddressRange range1 = IPv6AddressRange.fromFirstAndLast(start1, end1);
    ips = ipRange2.split("-");
      String startIp2 = ips[0];
      String endIp2 = null;
      if (ips.length > 1) {
        endIp2 = ips[1];
      }
      IPv6Address start2 = IPv6Address.fromString(startIp2);
      IPv6Address end2 = IPv6Address.fromString(endIp2);
      IPv6AddressRange range2 = IPv6AddressRange.fromFirstAndLast(start2, end2);
      return range1.overlaps(range2);
  }
View Full Code Here

        if (ips.length > 1) {
            endIp1 = ips[1];
        }
        IPv6Address start1 = IPv6Address.fromString(startIp1);
        IPv6Address end1 = IPv6Address.fromString(endIp1);
        IPv6AddressRange range1 = IPv6AddressRange.fromFirstAndLast(start1, end1);
        ips = ipRange2.split("-");
        String startIp2 = ips[0];
        String endIp2 = null;
        if (ips.length > 1) {
            endIp2 = ips[1];
        }
        IPv6Address start2 = IPv6Address.fromString(startIp2);
        IPv6Address end2 = IPv6Address.fromString(endIp2);
        IPv6AddressRange range2 = IPv6AddressRange.fromFirstAndLast(start2, end2);
        return range1.overlaps(range2);
    }
View Full Code Here

        if (ips.length > 1) {
            endIp1 = ips[1];
        }
        IPv6Address start1 = IPv6Address.fromString(startIp1);
        IPv6Address end1 = IPv6Address.fromString(endIp1);
        IPv6AddressRange range1 = IPv6AddressRange.fromFirstAndLast(start1, end1);
        ips = ipRange2.split("-");
        String startIp2 = ips[0];
        String endIp2 = null;
        if (ips.length > 1) {
            endIp2 = ips[1];
        }
        IPv6Address start2 = IPv6Address.fromString(startIp2);
        IPv6Address end2 = IPv6Address.fromString(endIp2);
        IPv6AddressRange range2 = IPv6AddressRange.fromFirstAndLast(start2, end2);
        return range1.overlaps(range2);
    }
View Full Code Here

        if (ips.length > 1) {
            endIp1 = ips[1];
        }
        IPv6Address start1 = IPv6Address.fromString(startIp1);
        IPv6Address end1 = IPv6Address.fromString(endIp1);
        IPv6AddressRange range1 = IPv6AddressRange.fromFirstAndLast(start1, end1);
        ips = ipRange2.split("-");
        String startIp2 = ips[0];
        String endIp2 = null;
        if (ips.length > 1) {
            endIp2 = ips[1];
        }
        IPv6Address start2 = IPv6Address.fromString(startIp2);
        IPv6Address end2 = IPv6Address.fromString(endIp2);
        IPv6AddressRange range2 = IPv6AddressRange.fromFirstAndLast(start2, end2);
        return range1.overlaps(range2);
    }
View Full Code Here

TOP

Related Classes of com.googlecode.ipv6.IPv6Network

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.