@Override protected Ipv6Address maybeIpv6Address(final IpAddress addr) { return addr.getIpv6Address(); } }
/** * Detects whether {@code IpAddress} is ipv6 */ public static boolean isIpv6(IpAddress address) { checkNotNull(address, "Address cannot be null"); checkState(!(address.getIpv4Address() == null && address.getIpv6Address() == null), "Invalid address"); return address.getIpv6Address() != null; }
public List<Ipv6Address> getIpv6AddressesWithoutLLA() { List<Ipv6Address> ipv6AddrList = new ArrayList<>(); for (SubnetInfo subnetInfo : snetInfo.values()) { if (subnetInfo.getIpAddr().getIpv6Address() instanceof Ipv6Address) { ipv6AddrList.add(subnetInfo.getIpAddr().getIpv6Address()); } } return ipv6AddrList; }
private IpAddress getRemoteIp() { final IpAddress remoteIp = StrictBGPPeerRegistry.getIpAddress(this.channel.remoteAddress()); if (remoteIp.getIpv6Address() != null) { return new IpAddress(Ipv6Util.getFullForm(remoteIp.getIpv6Address())); } return remoteIp; }
private static void serializeForwardingAddress(final IpAddress forwardingAddress, final ByteBuf byteAggregator) { if (forwardingAddress != null) { final ByteBuf ospfBuf = Unpooled.buffer(); if (forwardingAddress.getIpv4Address() != null) { ospfBuf.writeBytes(Ipv4Util.bytesForAddress(forwardingAddress.getIpv4Address())); } else if (forwardingAddress.getIpv6Address() != null) { ospfBuf.writeBytes(Ipv6Util.bytesForAddress(forwardingAddress.getIpv6Address())); } TlvUtil.writeTLV(FORWARDING_ADDRESS, ospfBuf, byteAggregator); } } }
public static String convertIpAddress(IpAddress ip) { String ret = null; if (ip != null) { if (ip.getIpv4Address() != null) { ret = ip.getIpv4Address().getValue(); } else if (ip.getIpv6Address() != null) { ret = ip.getIpv6Address().getValue(); } } return ret; }
private String getAddressString(final IpAddress address) { Preconditions.checkArgument(address.getIpv4Address() != null || address.getIpv6Address() != null, "Address %s is invalid", address); if (address.getIpv4Address() != null) { return address.getIpv4Address().getValue(); } return address.getIpv6Address().getValue(); }
private String getAddressString(final IpAddress address) { Preconditions.checkArgument(address.getIpv4Address() != null || address.getIpv6Address() != null, "Address %s is invalid", address); if (address.getIpv4Address() != null) { return address.getIpv4Address().getValue(); } return address.getIpv6Address().getValue(); }
public static String ipAddressToStringIpPrefix(IpAddress address) { if (address.getIpv4Address() != null) { return ipv4PrefixOf(address); } else if (address.getIpv6Address() != null) { return ipv6PrefixOf(address); } throw new IllegalArgumentException("Ip address [{}] is not a valid Ipv4 or Ipv6 address." + address); }
/** * Converts {@link IpAddress} to array representing {@link Ipv4Address} or {@link Ipv6Address} */ public static byte[] ipAddressToArray(boolean isIpv6, @Nonnull IpAddress address) { checkNotNull(address, "Cannot convert null Address"); if (isIpv6) { return ipv6AddressNoZoneToArray(new Ipv6AddressNoZone(address.getIpv6Address())); } else { return ipv4AddressNoZoneToArray(new Ipv4AddressNoZone(address.getIpv4Address())); } }
@Override public void readSpecific(@Nonnull InstanceIdentifier<Policy> id, @Nonnull ReadContext ctx, @Nonnull PolicyBuilder builder) throws ReadFailedException { PolicyKey key = id.firstKeyOf(Policy.class); Ipv6Address bsid = policyCtx.getPolicyBsid(key.getColor(), key.getEndpoint().getIpv6Address(), ctx.getMappingContext()); dumpManager.getDump(id, ctx.getModificationCache()).or(STATIC_EMPTY_REPLY).srPoliciesDetails.stream() .filter(srPoliciesDetails -> arrayToIpv6AddressNoZone(srPoliciesDetails.bsid.addr).getValue() .equals(bsid.getValue())) .findFirst() .ifPresent((SrPoliciesDetails details) -> bindPolicy(details, ctx, builder)); }
private static String getStringIpAddress(final IpAddress ipAddress) { if (ipAddress.getIpv4Address() != null) { return ipAddress.getIpv4Address().getValue(); } return ipAddress.getIpv6Address().getValue(); }
private String touniqueIpAddress(IpAddress ipAddress) { Ipv4Address ipv4 = ipAddress.getIpv4Address(); if (ipv4 != null) { return ipv4.getValue(); } Ipv6Address ipv6 = ipAddress.getIpv6Address(); if (ipv6 != null) { return uniqueIpv6String(ipv6.getValue()); } return null; } private static String uniqueIpv6String(String ipv6) {
private static String getStringIpAddress(IpAddress ipAddress) { if (ipAddress.getIpv4Address() != null) { return ipAddress.getIpv4Address().getValue(); } return ipAddress.getIpv6Address().getValue(); }
public static final byte[] ipAddressToArray(IpAddress address) { checkNotNull(address, "Cannot resolve null adddress"); if (isIpv6(address)) { return ipv6AddressNoZoneToArray(new Ipv6AddressNoZone(address.getIpv6Address())); } else { return ipv4AddressNoZoneToArray(new Ipv4AddressNoZone(address.getIpv4Address())); } }
private InetSocketAddress getInetAddress() { try { final InetAddress inetAd = InetAddress.getByName(getBindingAddress().getIpv4Address() == null ? getBindingAddress().getIpv6Address().getValue() : getBindingAddress().getIpv4Address().getValue()); return new InetSocketAddress(inetAd, getPort().getValue()); } catch (final UnknownHostException e) { throw new IllegalArgumentException("Unable to bind netconf endpoint to address " + getBindingAddress(), e); } }
private InetSocketAddress getAddress() { final InetAddress inetAddr; try { inetAddr = InetAddress.getByName(getBindingAddress() .getIpv4Address() != null ? getBindingAddress() .getIpv4Address().getValue() : getBindingAddress() .getIpv6Address().getValue()); } catch (final UnknownHostException e) { throw new IllegalArgumentException("Illegal binding address " + getBindingAddress(), e); } return new InetSocketAddress(inetAddr, getBindingPort().getValue()); }
private boolean isIpv6(final VxlanGpe vxlanGpe) { if (vxlanGpe.getLocal().getIpv4Address() == null) { checkArgument(vxlanGpe.getRemote().getIpv4Address() == null, "Inconsistent ip addresses: %s, %s", vxlanGpe.getLocal(), vxlanGpe.getRemote()); return true; } else { checkArgument(vxlanGpe.getRemote().getIpv6Address() == null, "Inconsistent ip addresses: %s, %s", vxlanGpe.getLocal(), vxlanGpe.getRemote()); return false; } }
private boolean isIpv6(final Gre gre) { if (gre.getSrc().getIpv4Address() == null) { checkArgument(gre.getDst().getIpv4Address() == null, "Inconsistent ip addresses: %s, %s", gre.getSrc(), gre.getDst()); return true; } else { checkArgument(gre.getDst().getIpv6Address() == null, "Inconsistent ip addresses: %s, %s", gre.getSrc(), gre.getDst()); return false; } }
public static IpPrefix ipAddressToIpPrefix(IpAddress address) { if (address.getIpv4Address() != null) { return new IpPrefix(new Ipv4Prefix(ipv4PrefixOf(address))); } else if (address.getIpv6Address() != null) { return new IpPrefix(new Ipv6Prefix(ipv6PrefixOf(address))); } throw new IllegalArgumentException("Ip address [{}] is not a valid Ipv4 or Ipv6 address." + address); }