public static Ipv6AddressNoZone getDefaultInstance(String defaultValue) { return new Ipv6AddressNoZone(defaultValue); }
public IpAddressNoZone(Ipv6AddressNoZone _ipv6AddressNoZone) { super(); this._ipv6AddressNoZone = _ipv6AddressNoZone; this._ipv4AddressNoZone = null; this._value = _ipv6AddressNoZone.getValue().toString().toCharArray(); }
@Nonnull protected Optional<IpAddressDetails> findIpv6AddressDetailsByIp( final Optional<IpAddressDetailsReplyDump> dump, @Nonnull final Ipv6AddressNoZone ip) { checkNotNull(ip, "ip address should not be null"); if (dump.isPresent() && dump.get().ipAddressDetails != null) { final List<IpAddressDetails> details = dump.get().ipAddressDetails; return Optional.of(details.stream() .filter(singleDetail -> ip.equals(arrayToIpv6AddressNoZone(singleDetail.ip))) .collect(RWUtils.singleItemCollector())); } return Optional.absent(); }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((_ipv4AddressNoZone == null) ? 0 : _ipv4AddressNoZone.hashCode()); result = prime * result + ((_ipv6AddressNoZone == null) ? 0 : _ipv6AddressNoZone.hashCode()); result = prime * result + ((_value == null) ? 0 : Arrays.hashCode(_value)); return result; }
/** * Creates a new instance from Ipv6Address * * @param source Source object */ public Ipv6AddressNoZone(Ipv6Address source) { super(source); CodeHelpers.checkPattern(getValue(), patterns, regexes); }
public static Ipv6AddressNoZone getDefaultInstance(String defaultValue) { return new Ipv6AddressNoZone(defaultValue); }
return false; } else if(!_ipv6AddressNoZone.equals(other._ipv6AddressNoZone)) { return false;
/** * Return a String representing the value of this union. * * @return String representation of this union's value. */ public String stringValue() { if (_ipv4AddressNoZone != null) { return _ipv4AddressNoZone.getValue().toString(); } if (_ipv6AddressNoZone != null) { return _ipv6AddressNoZone.getValue().toString(); } throw new IllegalStateException("No value assinged"); }
public static Ipv6AddressNoZone getDefaultInstance(String defaultValue) { return new Ipv6AddressNoZone(defaultValue); }
/** * Converts byte array to {@link Ipv6Prefix} with specified prefixLength */ public static Ipv6Prefix arrayToIpv6Prefix(final byte[] address, byte prefixLength) { Ipv6AddressNoZone addressPart = arrayToIpv6AddressNoZone(address); return new Ipv6Prefix(addressPart.getValue().concat("/").concat(String.valueOf(prefixLength))); }
public static IpAddressNoZone getDefaultInstance(final String defaultValue) { if (IPV4_NO_ZONE_PATTERN.matcher(defaultValue).matches()) { return new IpAddressNoZone((new Ipv4AddressNoZone(defaultValue))); } else if (IPV6_NO_ZONE_PATTERN1.matcher(defaultValue).matches()) { return new IpAddressNoZone((new Ipv6AddressNoZone(defaultValue))); } else { throw new IllegalArgumentException("Cannot create IpAddress from " + defaultValue); } } }
public List<NamedSegmentListKey> readNamedSegmentListKeys(final InstanceIdentifier<NamedSegmentList> id, final ReadContext ctx) throws ReadFailedException { return dumpManager.getDump(id, ctx.getModificationCache()).or(STATIC_EMPTY_REPLY).srPoliciesDetails.stream() .map(srPoliciesDetails -> { String bsid = arrayToIpv6AddressNoZone(srPoliciesDetails.bsid.addr).getValue(); return Arrays.stream(srPoliciesDetails.sidLists).map(srv6SidList -> srv6SidList.weight) .map(weight -> bsid + DASH_SEPARATOR + weight).collect(Collectors.toList()); }).flatMap(Collection::stream).map(NamedSegmentListKey::new).distinct().collect(Collectors.toList()); }
public static IpAddressNoZone getDefaultInstance(final String defaultValue) { if (IPV4_NO_ZONE_PATTERN.matcher(defaultValue).matches()) { return new IpAddressNoZone((new Ipv4AddressNoZone(defaultValue))); } else if (IPV6_NO_ZONE_PATTERN1.matcher(defaultValue).matches()) { return new IpAddressNoZone((new Ipv6AddressNoZone(defaultValue))); } else { throw new IllegalArgumentException("Cannot create IpAddress from " + defaultValue); } } }
public char[] getValue() { if (_value == null) { if (_ipv4AddressNoZone != null) { _value = _ipv4AddressNoZone.getValue().toString().toCharArray(); } else if (_ipv6AddressNoZone != null) { _value = _ipv6AddressNoZone.getValue().toString().toCharArray(); } } return _value == null ? null : _value.clone(); }
/** * Parse byte array returned by VPP representing an Ipv6 address. Vpp returns IP byte arrays in reversed order. * * @return Ipv46ddressNoZone containing string representation of IPv6 address constructed from submitted bytes. No * change in order. */ @Nonnull public static Ipv6AddressNoZone arrayToIpv6AddressNoZone(@Nonnull byte[] ip) { checkArgument(ip.length == 16, "Illegal array length"); try { return new Ipv6AddressNoZone(InetAddresses.toAddrString(InetAddresses.fromLittleEndianByteArray(ip))); } catch (UnknownHostException e) { throw new IllegalArgumentException("Unable to parse ipv6", e); } }
/** * Transform Ipv6 address to a byte array acceptable by VPP. VPP expects incoming byte array to be in the same order * as the address. * * @return byte array with address bytes */ public static byte[] ipv6AddressNoZoneToArray(@Nonnull final Ipv6AddressNoZone ipv6Addr) { byte[] retval = new byte[16]; //splits address and add ommited zeros for easier parsing List<String> segments = Arrays.asList(ipv6Addr.getValue().split(":")) .stream() .map(segment -> StringUtils.repeat('0', 4 - segment.length()) + segment) .collect(Collectors.toList()); byte index = 0; for (String segment : segments) { String firstPart = segment.substring(0, 2); String secondPart = segment.substring(2); //first part should be ommited if ("00".equals(firstPart)) { index++; } else { retval[index++] = ((byte) Short.parseShort(firstPart, 16)); } retval[index++] = ((byte) Short.parseShort(secondPart, 16)); } return retval; }
/** * Parse byte array returned by VPP representing an Ipv6 address. Vpp returns IP byte arrays in natural order. * * @return Ipv46ddressNoZone containing string representation of IPv6 address constructed from submitted bytes. No * change in order. */ @Nonnull public static Ipv6AddressNoZone arrayToIpv6AddressNoZoneReversed(@Nonnull byte[] ip) { checkArgument(ip.length == 16, "Illegal array length"); ip = reverseBytes(ip); try { return new Ipv6AddressNoZone(InetAddresses.toAddrString(InetAddresses.fromLittleEndianByteArray(ip))); } catch (UnknownHostException e) { throw new IllegalArgumentException("Unable to parse ipv6", e); } }
@Override public void readSpecific(@Nonnull final InstanceIdentifier<Locator> identifier, @Nonnull final ReadContext ctx, @Nonnull LocatorBuilder builder) throws ReadFailedException { final LocatorKey key = Preconditions.checkNotNull(identifier.firstKeyOf(Locator.class), "Identifier does not have %s ", LocatorKey.class); String locator = key.getName(); dumpManager.getDump(identifier, ctx.getModificationCache()).or(STATIC_EMPTY_REPLY).srLocalsidsDetails .stream() .filter(detail -> arrayToIpv6AddressNoZone(detail.addr.addr).getValue().contains(locator)) .findFirst() .ifPresent(srLocalsidsDetails -> bindLocalSid(srLocalsidsDetails, ctx.getMappingContext(), locator, builder)); }
/** * Creates address array from address part of {@link Ipv6Prefix} */ public static byte[] ipv6AddressPrefixToArray(@Nonnull final Ipv6Prefix ipv4Prefix) { checkNotNull(ipv4Prefix, "Cannot convert null prefix"); return ipv6AddressNoZoneToArray(new Ipv6AddressNoZone( new Ipv6Address(ipv4Prefix.getValue().substring(0, ipv4Prefix.getValue().indexOf('/'))))); }
@Override @Nonnull public List<SidKey> readAllKeys(@Nonnull InstanceIdentifier<Sid> identifier, @Nonnull ReadContext ctx) throws ReadFailedException { final LocatorKey key = Preconditions.checkNotNull(identifier.firstKeyOf(Locator.class), "Identifier does not have %s ", LocatorKey.class); String locator = key.getName(); return dumpManager.getDump(identifier, ctx.getModificationCache()).or(STATIC_EMPTY_REPLY).srLocalsidsDetails .stream() .filter(detail -> arrayToIpv6AddressNoZone(detail.addr.addr).getValue().contains(locator)) .map(srLocalsidsDetails -> extractOpCode(arrayToIpv6AddressNoZone(srLocalsidsDetails.addr.addr), ctx.getMappingContext(), locator)) .map(SidKey::new) .collect(Collectors.toList()); }