public Ipv6PrefixBuilder(Ipv6Prefix base) { this._ipv6Prefix = base.getIpv6Prefix(); if (base instanceof Ipv6PrefixImpl) { Ipv6PrefixImpl impl = (Ipv6PrefixImpl) base; if (!impl.augmentation.isEmpty()) { this.augmentation = new HashMap<>(impl.augmentation); } } else if (base instanceof AugmentationHolder) { @SuppressWarnings("unchecked") AugmentationHolder<Ipv6Prefix> casted =(AugmentationHolder<Ipv6Prefix>) base; if (!casted.augmentations().isEmpty()) { this.augmentation = new HashMap<>(casted.augmentations()); } } }
if (!Objects.equals(_ipv6Prefix, other.getIpv6Prefix())) { return false; if (!e.getValue().equals(other.augmentation(e.getKey()))) { return false;
public Ipv6PrefixBuilder(Ipv6Prefix base) { this._ipv6Prefix = base.getIpv6Prefix(); if (base instanceof Ipv6PrefixImpl) { Ipv6PrefixImpl impl = (Ipv6PrefixImpl) base; if (!impl.augmentation.isEmpty()) { this.augmentation = new HashMap<>(impl.augmentation); } } else if (base instanceof AugmentationHolder) { @SuppressWarnings("unchecked") Map<Class<? extends Augmentation<Ipv6Prefix>>, Augmentation<Ipv6Prefix>> aug =((AugmentationHolder<Ipv6Prefix>) base).augmentations(); if (!aug.isEmpty()) { this.augmentation = new HashMap<>(aug); } } }
if (!Objects.equals(_ipv6Prefix, other.getIpv6Prefix())) { return false; if (!e.getValue().equals(other.augmentation(e.getKey()))) { return false;
static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix v6LispPrefixToInetPrefix( final Ipv6Prefix prefix) { return new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix( prefix.getIpv6Prefix().getValue()); }
/** * Configuration data store whatever value is put, so it can be non-normalized, but * vpp optimize all eid prefix based values, returns true if such case */ default void checkIgnoredSubnetUpdate(@Nonnull final Address dataBefore, @Nonnull final Address dataAfter, @Nonnull Logger logger) { boolean isSameSubnet = false; if (dataBefore instanceof Ipv4Prefix && dataAfter instanceof Ipv4Prefix) { isSameSubnet = isSameSubnet(((Ipv4Prefix) dataBefore).getIpv4Prefix().getValue(), ((Ipv4Prefix) dataAfter).getIpv4Prefix().getValue()); } if (dataBefore instanceof Ipv6Prefix && dataAfter instanceof Ipv6Prefix) { isSameSubnet = isSameSubnet(((Ipv6Prefix) dataBefore).getIpv6Prefix().getValue(), ((Ipv6Prefix) dataAfter).getIpv6Prefix().getValue()); } if (isSameSubnet) { logger.warn("Attempt to update address within same subnet detected, ignoring[{} vs {}]", dataBefore, dataAfter); return; } throw new UnsupportedOperationException("Operation not supported"); }
static byte resolverPrefixLength(Address address) { switch (resolveType(address)) { case IPV4: return DEFAULT_V4_PREFIX; case IPV6: return DEFAULT_V6_PREFIX; case MAC: return 0; case IPV4_PREFIX: return extractPrefix(Ipv4Prefix.class.cast(address).getIpv4Prefix().getValue()); case IPV6_PREFIX: return extractPrefix(Ipv6Prefix.class.cast(address).getIpv6Prefix().getValue()); default: throw new IllegalArgumentException("Illegal type"); } }
private static IpPrefix getIpPrefix(Address address) { IpPrefix ipPrefix = null; if (address instanceof org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns .yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Prefix) { org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp .address.address.Ipv4Prefix lispPrefix = (org.opendaylight.yang.gen.v1.urn.ietf.params .xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Prefix) address; Ipv4Prefix inetPrefix = new Ipv4Prefix(lispPrefix.getIpv4Prefix()); ipPrefix = new IpPrefix(inetPrefix); } else if (address instanceof org.opendaylight.yang.gen.v1.urn.ietf.params .xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6Prefix) { org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp .address.address.Ipv6Prefix lispPrefix = (org.opendaylight.yang.gen.v1.urn.ietf.params .xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6Prefix) address; Ipv6Prefix inetPrefix = new Ipv6Prefix(lispPrefix.getIpv6Prefix()); ipPrefix = new IpPrefix(inetPrefix); } else { LOG.warn("Southbound mapping address is not an IpPrefix"); } return ipPrefix; } }
default boolean compareAddresses(Address firstAddress, Address secondAddress) { checkNotNull(firstAddress, "First address is null"); checkNotNull(secondAddress, "Second address is null"); if (firstAddress instanceof Ipv4 && secondAddress instanceof Ipv4) { return ((Ipv4) firstAddress).getIpv4().getValue().equals(((Ipv4) secondAddress).getIpv4().getValue()); } if (firstAddress instanceof Ipv6 && secondAddress instanceof Ipv6) { return ((Ipv6) firstAddress).getIpv6().getValue().equals(((Ipv6) secondAddress).getIpv6().getValue()); } if (firstAddress instanceof Mac && secondAddress instanceof Mac) { return ((Mac) firstAddress).getMac().getValue().equals(((Mac) secondAddress).getMac().getValue()); } if (firstAddress instanceof Ipv4Prefix && secondAddress instanceof Ipv4Prefix) { final String firstPrefix = ((Ipv4Prefix) firstAddress).getIpv4Prefix().getValue(); final String secondPrefix = ((Ipv4Prefix) secondAddress).getIpv4Prefix().getValue(); // for ex. 192.168.2.1/24 and 192.168.2.2/24 will be optimized to // 192.168.2.0/24 return isSameSubnet(firstPrefix, secondPrefix); } if (firstAddress instanceof Ipv6Prefix && secondAddress instanceof Ipv6Prefix) { final String firstPrefix = ((Ipv6Prefix) firstAddress).getIpv6Prefix().getValue(); final String secondPrefix = ((Ipv6Prefix) secondAddress).getIpv6Prefix().getValue(); // same here return isSameSubnet(firstPrefix, secondPrefix); } return false; }
default Address normalizeIfPrefixBased(Address address){ if(address instanceof Ipv4Prefix){ final String[] parts = ((Ipv4Prefix) address).getIpv4Prefix().getValue().split("/"); return new Ipv4PrefixBuilder().setIpv4Prefix( new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix( prefixValue(parts[0], parts[1]))) .build(); } if (address instanceof Ipv6Prefix){ final String[] parts = ((Ipv6Prefix) address).getIpv6Prefix().getValue().split("/"); return new Ipv6PrefixBuilder().setIpv6Prefix( new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix( prefixValue(parts[0], parts[1]))).build(); } // if not prefix based, does nothing return address; }