Package java.net

Examples of java.net.Inet6Address


      return LOOPBACK4;  // ::1
    } else if (leadingBytesOfZero && (bytes[15] == 0)) {
      return ANY4;  // ::0
    }

    Inet6Address ip6 = (Inet6Address) ip;
    long addressAsLong = 0;
    if (hasEmbeddedIPv4ClientAddress(ip6)) {
      addressAsLong = getEmbeddedIPv4ClientAddress(ip6).hashCode();
    } else {

      // Just extract the high 64 bits (assuming the rest is user-modifiable).
      addressAsLong = ByteBuffer.wrap(ip6.getAddress(), 0, 8).getLong();
    }

    // Many strategies for hashing are possible.  This might suffice for now.
    int coercedHash = hash64To32(addressAsLong);
View Full Code Here


           
            if (addr instanceof Inet4Address) {
                Inet4Address addr4 = (Inet4Address)addr;
                ret[2] = r.newFixnum(RubySocket.AF_INET); //AF_INET
            } else if (addr instanceof Inet6Address) {
                Inet6Address addr6 = (Inet6Address)addr;
                ret[2] = r.newFixnum(RubySocket.AF_INET6); //AF_INET
            }
            return r.newArrayNoCopy(ret);
        } catch(UnknownHostException e) {
            throw sockerr(context.getRuntime(), "gethostbyname: name or service not known");
View Full Code Here

      // HORNETQ-907 - strip off IPv6 scope-id (if necessary)
      SocketAddress remoteDestination = new InetSocketAddress(host, port);
      InetAddress inetAddress = ((InetSocketAddress) remoteDestination).getAddress();
      if (inetAddress instanceof Inet6Address)
      {
         Inet6Address inet6Address = (Inet6Address) inetAddress;
         if (inet6Address.getScopeId() != 0)
         {
            try
            {
               remoteDestination = new InetSocketAddress(InetAddress.getByAddress(inet6Address.getAddress()), ((InetSocketAddress) remoteDestination).getPort());
            }
            catch (UnknownHostException e)
            {
               throw new IllegalArgumentException(e.getMessage());
            }
View Full Code Here

    return country;
  }

  public static AsBlock find(InetAddress address) {
    if (address instanceof Inet6Address) {
      Inet6Address ipv6 = (Inet6Address) address;
      if (InetAddresses.is6to4Address(ipv6)) {
        InetAddress ipv4 = InetAddresses.get6to4IPv4Address(ipv6);
        return find(ipv4);
      }
    }
View Full Code Here

    InetAddress srcAddress = ((SshOpsTarget) src).getHost();
    InetAddress targetAddress = ((SshOpsTarget) target).getHost();

    if (srcAddress instanceof Inet4Address) {
      if (targetAddress instanceof Inet6Address) {
        Inet6Address srcIpv6 = findIpv6(src);
        if (srcIpv6 != null) {
          srcAddress = srcIpv6;
        } else {
          throw new UnsupportedOperationException();
        }
      }
    } else {
      if (targetAddress instanceof Inet4Address) {
        Inet6Address targetIpv6 = findIpv6(target);
        if (targetIpv6 != null) {
          targetAddress = targetIpv6;
        } else {
          throw new UnsupportedOperationException();
        }
View Full Code Here

    // TODO: This is outrageously inefficient
    List<IpV6Range> items = Lists.newArrayList();
    byte[] addr = getMasked();
    for (int i = 0; i < count; i++) {
      addBit(addr, bitCount + netmaskLength - 1);
      Inet6Address subAddress = (Inet6Address) toAddress(addr);
      items.add(new IpV6Range(subAddress, bitCount + netmaskLength));
    }

    return items;
  }
View Full Code Here

      String addressString = tokens.get(0);

      byte[] addr = Hex.fromHex(addressString);

      Inet6Address address;
      try {
        address = (Inet6Address) InetAddress.getByAddress(addr);
      } catch (UnknownHostException e) {
        throw new IllegalStateException("Error parsing IP address: " + line);
      }
View Full Code Here

            return false;
        }
    }

    public static InetAddress fixScopeIdAndGetInetAddress(final InetAddress inetAddress) throws SocketException {
        Inet6Address resultInetAddress = null;
        if (inetAddress instanceof Inet6Address &&
                (inetAddress.isLinkLocalAddress() || inetAddress.isSiteLocalAddress())) {
            final Inet6Address inet6Address = (Inet6Address) inetAddress;
            if (inet6Address.getScopeId() <= 0 && inet6Address.getScopedInterface() == null) {
                Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
                while (interfaces.hasMoreElements()) {
                    NetworkInterface ni = interfaces.nextElement();
                    Enumeration<InetAddress> addresses = ni.getInetAddresses();
                    while (addresses.hasMoreElements()) {
                        InetAddress address = addresses.nextElement();
                        if (address instanceof Inet6Address &&
                                Arrays.equals(address.getAddress(), inet6Address.getAddress())) {
                            if (resultInetAddress != null) {
                                throw new IllegalArgumentException("This address " + inet6Address +
                                        " is bound to more than one network interface!");
                            }
                            resultInetAddress = (Inet6Address) address;
View Full Code Here

                        if (address instanceof Inet4Address) {
                            continue;
                        }
                        if (inet6Address.isLinkLocalAddress() && address.isLinkLocalAddress()
                                || inet6Address.isSiteLocalAddress() && address.isSiteLocalAddress()) {
                            final Inet6Address newAddress = Inet6Address.getByAddress(null, inet6Address.getAddress(),
                                    ((Inet6Address) address).getScopeId());
                            possibleAddresses.addFirst(newAddress);
                        }
                    }
                }
View Full Code Here

    private static void processNetworkInterface(NetworkInterface nif) {
        for (InterfaceAddress ifaddr : nif.getInterfaceAddresses()) {
            InetAddress inetAddress = ifaddr.getAddress();
            if (inetAddress instanceof Inet6Address) {
                Inet6Address inet6 = (Inet6Address) inetAddress;
                if (inet6.isLoopbackAddress()) {
                    loopbackInterface = nif;
                    loopbackAddress = inet6;
                } else if (addresses.containsKey(nif)) {
                    addresses.get(nif).add(inet6);
                } else {
View Full Code Here

TOP

Related Classes of java.net.Inet6Address

Copyright © 2015 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.