public IpAddressNoZone(Ipv6AddressNoZone _ipv6AddressNoZone) { super(); this._ipv6AddressNoZone = _ipv6AddressNoZone; this._ipv4AddressNoZone = null; this._value = _ipv6AddressNoZone.getValue().toString().toCharArray(); }
/** * Creates a new instance from Ipv6Address * * @param source Source object */ public Ipv6AddressNoZone(Ipv6Address source) { super(source); CodeHelpers.checkPattern(getValue(), patterns, regexes); }
/** * 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 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()); }
/** * 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 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(); }
/** * 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; }
@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)); }
static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix v6Prefix( final byte[] address, final byte prefix) { return new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix( prefixValue(INSTANCE.arrayToIpv6AddressNoZone(address).getValue(), String.valueOf(prefix))); }
@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()); }
@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)); }
public void readNamedSegmentList(final InstanceIdentifier<NamedSegmentList> id, final NamedSegmentListBuilder builder, final ReadContext ctx) throws ReadFailedException { NamedSegmentListKey key = id.firstKeyOf(NamedSegmentList.class); builder.withKey(key) .setName(key.getName()) .setState( new org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.oc.srte.policy.rev170918.segment.list.properties.StateBuilder() .setName(key.getName()) .build()); Long weight = parseWeight(key); String bsid = parseBsid(key); Preconditions.checkNotNull(bsid, "Weight/Bsid not resolved for Iid: {}", id); builder.setSegments(new SegmentsBuilder().build()); dumpManager.getDump(id, ctx.getModificationCache()).or(STATIC_EMPTY_REPLY).srPoliciesDetails.stream() .filter(srPoliciesDetails -> arrayToIpv6AddressNoZone(srPoliciesDetails.bsid.addr).getValue() .equals(bsid)) .forEach(srPoliciesDetails -> Arrays.stream(srPoliciesDetails.sidLists) .forEach(srv6SidList -> { if (srv6SidList.weight == weight.intValue()) { List<Segment> segments = IntStream.range(0, srv6SidList.numSids) .mapToObj(i -> parseSrv6Sid(i, srv6SidList.sids[i])) .collect(Collectors.toList()); builder.setSegments(new SegmentsBuilder().setSegment(segments).build()); } })); }
default String getArrayAsEidString(final EidType type, final byte[] address, final byte prefix) { switch (type) { case IPV4: { return prefix != DEFAULT_V4_PREFIX ? v4Prefix(address, prefix).getValue() : arrayToIpv4AddressNoZone(address).getValue(); } case IPV6: { return prefix != DEFAULT_V6_PREFIX ? v6Prefix(address, prefix).getValue() : arrayToIpv6AddressNoZone(address).getValue(); } case MAC: { //as wrong as it looks ,its right(second param is not end index,but count) return byteArrayToMacSeparated(Arrays.copyOfRange(address, 0, 6)); } case IPV4_PREFIX: { return v4Prefix(address, prefix).getValue(); } case IPV6_PREFIX: { return v6Prefix(address, prefix).getValue(); } default: { throw new IllegalStateException("Unknown type detected"); } } }