summaryrefslogtreecommitdiffstats
path: root/v3po/v3po2vpp/src/main/java/io
diff options
context:
space:
mode:
authorJan Srnicek <jsrnicek@cisco.com>2016-11-24 11:56:40 +0100
committerJan Srnicek <jsrnicek@cisco.com>2016-11-24 11:56:40 +0100
commite259ab7990b8179eda4462907ecebccd0e85b587 (patch)
treeb0326a66b0a9d775e79dfbc495568df94643f3ef /v3po/v3po2vpp/src/main/java/io
parent927fb75d969b2d39c91ae6735f0127646348b73c (diff)
HON-3 - Address logic refactoring
Ipv4/6 address logic refactored to not use InetAddresses.fromLittleEndianArray to prevent unnecessary reverting of address arrays after fix introduced by VPP-132. Removed unused ***reverted variants of conversion logic. Tested with these plugins - Lisp - V3po - Nat Change-Id: I6a0728f8b3dffd04e2edd822ec61542216cca824 Signed-off-by: Jan Srnicek <jsrnicek@cisco.com>
Diffstat (limited to 'v3po/v3po2vpp/src/main/java/io')
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/ip/Ipv4AddressCustomizer.java52
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/ip/Ipv4Reader.java14
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/ip/SubInterfaceIpv4AddressCustomizer.java2
3 files changed, 33 insertions, 35 deletions
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/ip/Ipv4AddressCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/ip/Ipv4AddressCustomizer.java
index 43d82ec5e..a3e12faea 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/ip/Ipv4AddressCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/ip/Ipv4AddressCustomizer.java
@@ -77,30 +77,6 @@ public class Ipv4AddressCustomizer extends FutureJVppCustomizer
.build();
}
- private static Subnet getSubnet(final Address address) {
- final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces.state._interface.ipv4.address.Subnet
- subnet = address.getSubnet();
-
- // Only prefix length supported
- Preconditions.checkArgument(
- subnet instanceof org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces.state._interface.ipv4.address.subnet.PrefixLength);
-
- return new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv4.address.subnet.PrefixLengthBuilder()
- .setPrefixLength(
- ((org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces.state._interface.ipv4.address.subnet.PrefixLength) subnet)
- .getPrefixLength()).build();
- }
-
- static InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv4.Address> getCfgId(
- final InstanceIdentifier<Address> id) {
- return InterfaceCustomizer.getCfgId(RWUtils.cutId(id, Interface.class))
- .augmentation(Interface1.class)
- .child(Ipv4.class)
- .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv4.Address.class,
- new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv4.AddressKey(
- id.firstKeyOf(Address.class).getIp()));
- }
-
@Override
@Nonnull
public AddressBuilder getBuilder(@Nonnull InstanceIdentifier<Address> id) {
@@ -126,9 +102,8 @@ public class Ipv4AddressCustomizer extends FutureJVppCustomizer
if (ipAddressDetails.isPresent()) {
final IpAddressDetails detail = ipAddressDetails.get();
- builder.setIp(arrayToIpv4AddressNoZoneReversed(detail.ip))
- .setSubnet(
- new PrefixLengthBuilder().setPrefixLength(Short.valueOf(detail.prefixLength)).build());
+ builder.setIp(arrayToIpv4AddressNoZone(detail.ip))
+ .setSubnet(new PrefixLengthBuilder().setPrefixLength(Short.valueOf(detail.prefixLength)).build());
if (LOG.isDebugEnabled()) {
LOG.debug("Attributes for {} interface (id={}) address {} successfully read: {}",
@@ -165,4 +140,27 @@ public class Ipv4AddressCustomizer extends FutureJVppCustomizer
.setSubnet(getSubnet(readValue))
.build());
}
+
+ private static Subnet getSubnet(final Address address) {
+ final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces.state._interface.ipv4.address.Subnet
+ subnet = address.getSubnet();
+
+ // Only prefix length supported
+ Preconditions.checkArgument(
+ subnet instanceof org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces.state._interface.ipv4.address.subnet.PrefixLength);
+
+ return new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv4.address.subnet.PrefixLengthBuilder()
+ .setPrefixLength(
+ ((org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces.state._interface.ipv4.address.subnet.PrefixLength) subnet)
+ .getPrefixLength()).build();
+ }
+
+ static InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv4.Address> getCfgId(
+ final InstanceIdentifier<Address> id) {
+ return InterfaceCustomizer.getCfgId(RWUtils.cutId(id, Interface.class))
+ .augmentation(Interface1.class)
+ .child(Ipv4.class)
+ .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv4.Address.class,
+ new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv4.AddressKey(id.firstKeyOf(Address.class).getIp()));
+ }
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/ip/Ipv4Reader.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/ip/Ipv4Reader.java
index 4caaa5922..8c8299dbd 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/ip/Ipv4Reader.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/ip/Ipv4Reader.java
@@ -19,11 +19,13 @@ package io.fd.hc2vpp.v3po.interfacesstate.ip;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.base.Optional;
-import io.fd.honeycomb.translate.util.RWUtils;
-import io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor;
-import io.fd.hc2vpp.v3po.interfacesstate.ip.dump.params.AddressDumpParams;
import io.fd.hc2vpp.common.translate.util.Ipv4Translator;
import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
+import io.fd.hc2vpp.v3po.interfacesstate.ip.dump.params.AddressDumpParams;
+import io.fd.honeycomb.translate.util.RWUtils;
+import io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor;
+import io.fd.vpp.jvpp.core.dto.IpAddressDetails;
+import io.fd.vpp.jvpp.core.dto.IpAddressDetailsReplyDump;
import io.fd.vpp.jvpp.core.dto.IpAddressDump;
import io.fd.vpp.jvpp.core.future.FutureJVppCore;
import java.util.Collections;
@@ -33,8 +35,6 @@ import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone;
import org.opendaylight.yangtools.yang.binding.Identifier;
-import io.fd.vpp.jvpp.core.dto.IpAddressDetails;
-import io.fd.vpp.jvpp.core.dto.IpAddressDetailsReplyDump;
/**
* Utility class providing Ipv4 read support.
@@ -47,7 +47,7 @@ interface Ipv4Reader extends Ipv4Translator, JvppReplyConsumer {
@Nonnull final Function<Ipv4AddressNoZone, T> keyConstructor) {
if (dumpOptional.isPresent() && dumpOptional.get().ipAddressDetails != null) {
return dumpOptional.get().ipAddressDetails.stream()
- .map(detail -> keyConstructor.apply(arrayToIpv4AddressNoZoneReversed(detail.ip)))
+ .map(detail -> keyConstructor.apply(arrayToIpv4AddressNoZone(detail.ip)))
.collect(Collectors.toList());
} else {
return Collections.emptyList();
@@ -63,7 +63,7 @@ interface Ipv4Reader extends Ipv4Translator, JvppReplyConsumer {
final List<IpAddressDetails> details = dump.get().ipAddressDetails;
return Optional.of(details.stream()
- .filter(singleDetail -> ip.equals(arrayToIpv4AddressNoZoneReversed(singleDetail.ip)))
+ .filter(singleDetail -> ip.equals(arrayToIpv4AddressNoZone(singleDetail.ip)))
.collect(RWUtils.singleItemCollector()));
}
return Optional.absent();
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/ip/SubInterfaceIpv4AddressCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/ip/SubInterfaceIpv4AddressCustomizer.java
index cb239dc9f..a8617c578 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/ip/SubInterfaceIpv4AddressCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/ip/SubInterfaceIpv4AddressCustomizer.java
@@ -101,7 +101,7 @@ public class SubInterfaceIpv4AddressCustomizer extends FutureJVppCustomizer
if (ipAddressDetails.isPresent()) {
final IpAddressDetails detail = ipAddressDetails.get();
- builder.setIp(arrayToIpv4AddressNoZoneReversed(detail.ip));
+ builder.setIp(arrayToIpv4AddressNoZone(detail.ip));
builder.setSubnet(new PrefixLengthBuilder().setPrefixLength(Short.valueOf(detail.prefixLength)).build());
if (LOG.isDebugEnabled()) {