summaryrefslogtreecommitdiffstats
path: root/nat
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 /nat
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 'nat')
-rw-r--r--nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ExternalIpPoolCustomizer.java7
-rw-r--r--nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/MappingEntryCustomizer.java8
-rw-r--r--nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/util/MappingEntryContext.java10
3 files changed, 12 insertions, 13 deletions
diff --git a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ExternalIpPoolCustomizer.java b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ExternalIpPoolCustomizer.java
index 615d9c70f..1a6742648 100644
--- a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ExternalIpPoolCustomizer.java
+++ b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ExternalIpPoolCustomizer.java
@@ -16,6 +16,8 @@
package io.fd.hc2vpp.nat.read;
+import io.fd.hc2vpp.common.translate.util.Ipv4Translator;
+import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.Initialized;
@@ -23,8 +25,6 @@ import io.fd.honeycomb.translate.spi.read.InitializingListReaderCustomizer;
import io.fd.honeycomb.translate.util.RWUtils;
import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager;
import io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor;
-import io.fd.hc2vpp.common.translate.util.Ipv4Translator;
-import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
import io.fd.vpp.jvpp.snat.dto.SnatAddressDetails;
import io.fd.vpp.jvpp.snat.dto.SnatAddressDetailsReplyDump;
import io.fd.vpp.jvpp.snat.dto.SnatAddressDump;
@@ -76,8 +76,7 @@ final class ExternalIpPoolCustomizer implements
dumpMgr.getDump(id, ctx.getModificationCache(), null)
.or(new SnatAddressDetailsReplyDump()).snatAddressDetails.get(Math.toIntExact(poolId));
- builder.setExternalIpPool(
- new Ipv4Prefix(arrayToIpv4AddressNoZoneReversed(details.ipAddress).getValue() + "/32"));
+ builder.setExternalIpPool(new Ipv4Prefix(arrayToIpv4AddressNoZone(details.ipAddress).getValue() + "/32"));
builder.setPoolId(poolId);
LOG.trace("External IP pool: {}. Read as: {}", id, builder);
diff --git a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/MappingEntryCustomizer.java b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/MappingEntryCustomizer.java
index 75e06c26f..ae4f11917 100644
--- a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/MappingEntryCustomizer.java
+++ b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/MappingEntryCustomizer.java
@@ -16,6 +16,8 @@
package io.fd.hc2vpp.nat.read;
+import io.fd.hc2vpp.common.translate.util.Ipv4Translator;
+import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
import io.fd.hc2vpp.nat.util.MappingEntryContext;
import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.read.ReadFailedException;
@@ -24,8 +26,6 @@ import io.fd.honeycomb.translate.spi.read.InitializingListReaderCustomizer;
import io.fd.honeycomb.translate.util.RWUtils;
import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager;
import io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor;
-import io.fd.hc2vpp.common.translate.util.Ipv4Translator;
-import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
import io.fd.vpp.jvpp.snat.dto.SnatStaticMappingDetails;
import io.fd.vpp.jvpp.snat.dto.SnatStaticMappingDetailsReplyDump;
import io.fd.vpp.jvpp.snat.dto.SnatStaticMappingDump;
@@ -89,9 +89,9 @@ final class MappingEntryCustomizer implements Ipv4Translator,
builder.setType(
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.nat.rev150908.MappingEntry.Type.Static);
// Snat only supports ipv4 for now
- builder.setExternalSrcAddress(arrayToIpv4AddressNoZoneReversed(snatStaticMappingDetails.externalIpAddress));
+ builder.setExternalSrcAddress(arrayToIpv4AddressNoZone(snatStaticMappingDetails.externalIpAddress));
builder.setInternalSrcAddress(
- new IpAddress(arrayToIpv4AddressNoZoneReversed(snatStaticMappingDetails.localIpAddress)));
+ new IpAddress(arrayToIpv4AddressNoZone(snatStaticMappingDetails.localIpAddress)));
if (snatStaticMappingDetails.addrOnly == 0) {
builder.setExternalSrcPort(new ExternalSrcPortBuilder()
diff --git a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/util/MappingEntryContext.java b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/util/MappingEntryContext.java
index 6db8d468c..afdf8abae 100644
--- a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/util/MappingEntryContext.java
+++ b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/util/MappingEntryContext.java
@@ -20,8 +20,8 @@ import static com.google.common.base.Preconditions.checkArgument;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Optional;
-import io.fd.honeycomb.translate.MappingContext;
import io.fd.hc2vpp.common.translate.util.Ipv4Translator;
+import io.fd.honeycomb.translate.MappingContext;
import io.fd.vpp.jvpp.snat.dto.SnatStaticMappingDetails;
import java.util.Collections;
import java.util.Comparator;
@@ -97,20 +97,20 @@ public class MappingEntryContext implements Ipv4Translator {
private MappingEntryKey entryToKey(final SnatStaticMappingDetails entry) {
// Only IPv4
return new MappingEntryKey(
- new IpAddress(new Ipv4Address(arrayToIpv4AddressNoZoneReversed(entry.externalIpAddress))),
- new IpAddress(new Ipv4Address(arrayToIpv4AddressNoZoneReversed(entry.localIpAddress))));
+ new IpAddress(new Ipv4Address(arrayToIpv4AddressNoZone(entry.externalIpAddress))),
+ new IpAddress(new Ipv4Address(arrayToIpv4AddressNoZone(entry.localIpAddress))));
}
private boolean equalEntries(final SnatStaticMappingDetails detail, final MappingEntry ctxMappingEntry) {
final IpAddress internalAddrFromDetails =
- new IpAddress(new Ipv4Address(arrayToIpv4AddressNoZoneReversed(detail.localIpAddress)));
+ new IpAddress(new Ipv4Address(arrayToIpv4AddressNoZone(detail.localIpAddress)));
// Only IPv4
if (!ctxMappingEntry.getInternal().equals(internalAddrFromDetails)) {
return false;
}
// Only IPv4
final IpAddress externalAddrFromDetails =
- new IpAddress(new Ipv4Address(arrayToIpv4AddressNoZoneReversed(detail.externalIpAddress)));
+ new IpAddress(new Ipv4Address(arrayToIpv4AddressNoZone(detail.externalIpAddress)));
if (!ctxMappingEntry.getExternal().equals(externalAddrFromDetails)) {
return false;
}