summaryrefslogtreecommitdiffstats
path: root/nat
diff options
context:
space:
mode:
authorMichal Cmarada <mcmarada@cisco.com>2019-05-06 13:48:21 +0200
committerMichal Cmarada <mcmarada@cisco.com>2019-05-06 13:48:21 +0200
commit97554c44ffc7f7ce82fe89d6da5ac15c46ee80b4 (patch)
treed1756819a8e108ab381129e747575c9515e0072e /nat
parentb248447c7ab16c86b28e9bda5f7224a9d106ac43 (diff)
fix Nat implementation after API changes in VPP
Change-Id: Ibe8ead5a19119af9eb6b673f0713890ad5e243cb Signed-off-by: Michal Cmarada <mcmarada@cisco.com>
Diffstat (limited to 'nat')
-rw-r--r--nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ExternalIpPoolCustomizer.java4
-rw-r--r--nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/MappingEntryCustomizer.java13
-rw-r--r--nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/Nat64PrefixesCustomizer.java2
-rw-r--r--nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ifc/AbstractInterfaceNatCustomizer.java15
-rw-r--r--nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ifc/InterfaceInboundNatCustomizer.java5
-rw-r--r--nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ifc/InterfaceOutboundNatCustomizer.java5
-rw-r--r--nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ifc/SubInterfaceInboundNatCustomizer.java5
-rw-r--r--nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ifc/SubInterfaceOutboundNatCustomizer.java5
-rw-r--r--nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/util/MappingEntryContext.java18
-rw-r--r--nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/write/ExternalIpPoolCustomizer.java12
-rw-r--r--nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/write/MappingEntryCustomizer.java27
-rw-r--r--nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/write/Nat64PrefixesCustomizer.java5
-rw-r--r--nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/write/ifc/AbstractInterfaceNatCustomizer.java44
-rw-r--r--nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/ExternalIpPoolCustomizerTest.java19
-rw-r--r--nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/MappingEntryCustomizerTest.java54
-rw-r--r--nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/Nat64PrefixesCustomizerTest.java15
-rw-r--r--nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/ifc/InterfaceInboundNatCustomizerTest.java14
-rw-r--r--nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/ifc/InterfaceOutboundNatCustomizerTest.java14
-rw-r--r--nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/util/MappingEntryContextTest.java11
-rw-r--r--nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/ExternalIpPoolCustomizerTest.java17
-rw-r--r--nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/MappingEntryCustomizerTest.java50
-rw-r--r--nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/Nat64PrefixesCustomizerTest.java11
-rw-r--r--nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/ifc/AbstractNatCustomizerTest.java39
23 files changed, 270 insertions, 134 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 7a97a68d1..574d05862 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
@@ -102,7 +102,7 @@ final class ExternalIpPoolCustomizer implements
// Uses ID<->address mapping as defined by getAllIds (nat44 mappings go before nat64):
if (poolId < nat44PoolCount) {
final Nat44AddressDetails detail = nat44Details.get(Math.toIntExact(poolId));
- readPoolIp(builder, detail.ipAddress);
+ readPoolIp(builder, detail.ipAddress.ip4Address);
setPoolType(builder, NatPoolType.Nat44);
} else {
final List<Nat64PoolAddrDetails> nat64Details = nat64DumpMgr.getDump(id, ctx.getModificationCache())
@@ -111,7 +111,7 @@ final class ExternalIpPoolCustomizer implements
final int nat64PoolPosition = Math.toIntExact(poolId) - nat44PoolCount;
if (nat64PoolPosition < nat64PoolCount) {
final Nat64PoolAddrDetails detail = nat64Details.get(nat64PoolPosition);
- readPoolIp(builder, detail.address);
+ readPoolIp(builder, detail.address.ip4Address);
setPoolType(builder, NatPoolType.Nat64);
} else {
// Address pool for given ID is missing (legal state).
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 1ae452183..70dc10b44 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
@@ -33,6 +33,7 @@ import io.fd.jvpp.nat.dto.Nat64BibDetails;
import io.fd.jvpp.nat.dto.Nat64BibDetailsReplyDump;
import io.fd.jvpp.nat.dto.Nat64BibDump;
import io.fd.jvpp.nat.future.FutureJVppNatFacade;
+import io.fd.jvpp.nat.types.NatConfigFlags;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
@@ -114,10 +115,10 @@ final class MappingEntryCustomizer implements Ipv4Translator, Ipv6Translator,
builder.setIndex((long) index);
builder.setType(
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.nat.rev180628.MappingEntry.Type.Static);
- builder.setExternalSrcAddress(new IpPrefix(toIpv4Prefix(detail.externalIpAddress, 32)));
- builder.setInternalSrcAddress(new IpPrefix(toIpv4Prefix(detail.localIpAddress, 32)));
+ builder.setExternalSrcAddress(new IpPrefix(toIpv4Prefix(detail.externalIpAddress.ip4Address, 32)));
+ builder.setInternalSrcAddress(new IpPrefix(toIpv4Prefix(detail.localIpAddress.ip4Address, 32)));
- if (detail.addrOnly == 0) {
+ if (!detail.flags.contains(NatConfigFlags.NatConfigFlagsOptions.NAT_IS_ADDR_ONLY)) {
builder.setExternalSrcPort(new ExternalSrcPortBuilder()
.setStartPortNumber(new PortNumber(Short.toUnsignedInt(detail.externalPort))).build());
builder.setInternalSrcPort(new InternalSrcPortBuilder()
@@ -128,15 +129,15 @@ final class MappingEntryCustomizer implements Ipv4Translator, Ipv6Translator,
private void readNat64Entry(@Nonnull final MappingEntryBuilder builder,
final int index, final Nat64BibDetails detail) {
builder.setIndex((long) index);
- if (detail.isStatic == 1) {
+ if (detail.flags.contains(NatConfigFlags.NatConfigFlagsOptions.NAT_IS_STATIC)) {
builder.setType(
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.nat.rev180628.MappingEntry.Type.Static);
} else {
builder.setType(
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.nat.rev180628.MappingEntry.Type.DynamicImplicit);
}
- builder.setExternalSrcAddress(new IpPrefix(toIpv4Prefix(detail.oAddr,32 )));
- builder.setInternalSrcAddress(new IpPrefix(toIpv6Prefix(detail.iAddr, 128)));
+ builder.setExternalSrcAddress(new IpPrefix(toIpv4Prefix(detail.oAddr.ip4Address, 32)));
+ builder.setInternalSrcAddress(new IpPrefix(toIpv6Prefix(detail.iAddr.ip6Address, 128)));
builder.setExternalSrcPort(new ExternalSrcPortBuilder()
.setStartPortNumber(new PortNumber(Short.toUnsignedInt(detail.oPort))).build());
diff --git a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/Nat64PrefixesCustomizer.java b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/Nat64PrefixesCustomizer.java
index 6e955ea64..468008c46 100644
--- a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/Nat64PrefixesCustomizer.java
+++ b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/Nat64PrefixesCustomizer.java
@@ -111,7 +111,7 @@ final class Nat64PrefixesCustomizer
}
private Ipv6Prefix readPrefix(final Nat64PrefixDetails details) {
- return toIpv6Prefix(details.prefix, UnsignedBytes.toInt(details.prefixLen));
+ return toIpv6Prefix(details.prefix.prefix.ip6Address, UnsignedBytes.toInt(details.prefix.len));
}
private final class Nat64PrefixesExecutor implements EntityDumpExecutor<Map<Long, Nat64PrefixDetails>, Void> {
diff --git a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ifc/AbstractInterfaceNatCustomizer.java b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ifc/AbstractInterfaceNatCustomizer.java
index 2d8e4cce5..8ce475b38 100644
--- a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ifc/AbstractInterfaceNatCustomizer.java
+++ b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ifc/AbstractInterfaceNatCustomizer.java
@@ -31,6 +31,7 @@ import io.fd.jvpp.nat.dto.Nat44InterfaceOutputFeatureDump;
import io.fd.jvpp.nat.dto.Nat64InterfaceDetailsReplyDump;
import io.fd.jvpp.nat.dto.Nat64InterfaceDump;
import io.fd.jvpp.nat.future.FutureJVppNatFacade;
+import io.fd.jvpp.nat.types.NatConfigFlags;
import java.util.Optional;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
@@ -96,8 +97,8 @@ abstract class AbstractInterfaceNatCustomizer<C extends DataObject, B extends Bu
preRoutingNat44DumpMgr.getDump(id, ctx.getModificationCache());
dump.orElse(new Nat44InterfaceDetailsReplyDump()).nat44InterfaceDetails.stream()
- .filter(natIfcDetail -> natIfcDetail.swIfIndex == index)
- .filter(natIfcDetail -> isExpectedNatType(natIfcDetail.isInside))
+ .filter(natIfcDetail -> natIfcDetail.swIfIndex.interfaceindex == index)
+ .filter(natIfcDetail -> isExpectedNatType(natIfcDetail.flags))
.findAny()
.ifPresent(natIfcDetail -> vppAttributesBuilder.enableNat44(builder));
// do not modify builder is feature is absent (inbound/outbound are presence containers)
@@ -109,8 +110,8 @@ abstract class AbstractInterfaceNatCustomizer<C extends DataObject, B extends Bu
preRoutingNat64DumpMgr.getDump(id, ctx.getModificationCache());
dump.orElse(new Nat64InterfaceDetailsReplyDump()).nat64InterfaceDetails.stream()
- .filter(natIfcDetail -> natIfcDetail.swIfIndex == index)
- .filter(natIfcDetail -> isExpectedNatType(natIfcDetail.isInside))
+ .filter(natIfcDetail -> natIfcDetail.swIfIndex.interfaceindex == index)
+ .filter(natIfcDetail -> isExpectedNatType(natIfcDetail.flags))
.findAny()
.ifPresent(natIfcDetail -> vppAttributesBuilder.enableNat64(builder));
// do not modify builder is feature is absent (inbound/outbound are presence containers)
@@ -123,8 +124,8 @@ abstract class AbstractInterfaceNatCustomizer<C extends DataObject, B extends Bu
dump.orElse(new Nat44InterfaceOutputFeatureDetailsReplyDump()).nat44InterfaceOutputFeatureDetails
.stream()
- .filter(natIfcDetail -> natIfcDetail.swIfIndex == index)
- .filter(natIfcDetail -> isExpectedNatType(natIfcDetail.isInside))
+ .filter(natIfcDetail -> natIfcDetail.swIfIndex.interfaceindex == index)
+ .filter(natIfcDetail -> isExpectedNatType(natIfcDetail.flags))
.findAny()
.ifPresent(natIfcDetail -> vppAttributesBuilder.enablePostRouting(builder));
// do not modify builder is feature is absent (inbound/outbound are presence containers)
@@ -136,5 +137,5 @@ abstract class AbstractInterfaceNatCustomizer<C extends DataObject, B extends Bu
abstract Logger getLog();
- abstract boolean isExpectedNatType(final int isInside);
+ abstract boolean isExpectedNatType(final NatConfigFlags flags);
}
diff --git a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ifc/InterfaceInboundNatCustomizer.java b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ifc/InterfaceInboundNatCustomizer.java
index 76a20a94c..c0dde6516 100644
--- a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ifc/InterfaceInboundNatCustomizer.java
+++ b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ifc/InterfaceInboundNatCustomizer.java
@@ -20,6 +20,7 @@ import io.fd.hc2vpp.common.translate.util.NamingContext;
import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.spi.read.Initialized;
import io.fd.jvpp.nat.future.FutureJVppNatFacade;
+import io.fd.jvpp.nat.types.NatConfigFlags;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang._interface.nat.rev170816.NatInterfaceAugmentation;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang._interface.nat.rev170816._interface.nat.attributes.Nat;
@@ -50,8 +51,8 @@ final class InterfaceInboundNatCustomizer extends AbstractInterfaceNatCustomizer
}
@Override
- boolean isExpectedNatType(final int isInside) {
- return isInside == 1;
+ boolean isExpectedNatType(final NatConfigFlags flags) {
+ return flags.contains(NatConfigFlags.NatConfigFlagsOptions.NAT_IS_INSIDE);
}
@Nonnull
diff --git a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ifc/InterfaceOutboundNatCustomizer.java b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ifc/InterfaceOutboundNatCustomizer.java
index 68c0cb1ce..3196cda10 100644
--- a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ifc/InterfaceOutboundNatCustomizer.java
+++ b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ifc/InterfaceOutboundNatCustomizer.java
@@ -20,6 +20,7 @@ import io.fd.hc2vpp.common.translate.util.NamingContext;
import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.spi.read.Initialized;
import io.fd.jvpp.nat.future.FutureJVppNatFacade;
+import io.fd.jvpp.nat.types.NatConfigFlags;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang._interface.nat.rev170816.NatInterfaceAugmentation;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang._interface.nat.rev170816._interface.nat.attributes.Nat;
@@ -50,8 +51,8 @@ final class InterfaceOutboundNatCustomizer extends AbstractInterfaceNatCustomize
}
@Override
- boolean isExpectedNatType(final int isInside) {
- return isInside == 0;
+ boolean isExpectedNatType(final NatConfigFlags flags) {
+ return flags.contains(NatConfigFlags.NatConfigFlagsOptions.NAT_IS_OUTSIDE);
}
@Nonnull
diff --git a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ifc/SubInterfaceInboundNatCustomizer.java b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ifc/SubInterfaceInboundNatCustomizer.java
index 0ca344419..c9f4dc888 100644
--- a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ifc/SubInterfaceInboundNatCustomizer.java
+++ b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ifc/SubInterfaceInboundNatCustomizer.java
@@ -20,6 +20,7 @@ import io.fd.hc2vpp.common.translate.util.NamingContext;
import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.spi.read.Initialized;
import io.fd.jvpp.nat.future.FutureJVppNatFacade;
+import io.fd.jvpp.nat.types.NatConfigFlags;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang._interface.nat.rev170816._interface.nat.attributes.Nat;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang._interface.nat.rev170816._interface.nat.attributes.NatBuilder;
@@ -54,8 +55,8 @@ final class SubInterfaceInboundNatCustomizer extends AbstractSubInterfaceNatCust
}
@Override
- boolean isExpectedNatType(final int isInside) {
- return isInside == 1;
+ boolean isExpectedNatType(final NatConfigFlags flags) {
+ return flags.contains(NatConfigFlags.NatConfigFlagsOptions.NAT_IS_INSIDE);
}
@Nonnull
diff --git a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ifc/SubInterfaceOutboundNatCustomizer.java b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ifc/SubInterfaceOutboundNatCustomizer.java
index 92d829987..8485cded9 100644
--- a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ifc/SubInterfaceOutboundNatCustomizer.java
+++ b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ifc/SubInterfaceOutboundNatCustomizer.java
@@ -20,6 +20,7 @@ import io.fd.hc2vpp.common.translate.util.NamingContext;
import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.spi.read.Initialized;
import io.fd.jvpp.nat.future.FutureJVppNatFacade;
+import io.fd.jvpp.nat.types.NatConfigFlags;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang._interface.nat.rev170816._interface.nat.attributes.Nat;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang._interface.nat.rev170816._interface.nat.attributes.NatBuilder;
@@ -54,8 +55,8 @@ final class SubInterfaceOutboundNatCustomizer extends AbstractSubInterfaceNatCus
}
@Override
- boolean isExpectedNatType(final int isInside) {
- return isInside == 0;
+ boolean isExpectedNatType(final NatConfigFlags flags) {
+ return flags.contains(NatConfigFlags.NatConfigFlagsOptions.NAT_IS_OUTSIDE);
}
@Nonnull
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 aed383b10..67e29ccb2 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
@@ -19,7 +19,6 @@ package io.fd.hc2vpp.nat.util;
import static com.google.common.base.Preconditions.checkArgument;
import com.google.common.annotations.VisibleForTesting;
-import java.util.Optional;
import io.fd.hc2vpp.common.translate.util.Ipv4Translator;
import io.fd.hc2vpp.common.translate.util.Ipv6Translator;
import io.fd.honeycomb.translate.MappingContext;
@@ -28,6 +27,7 @@ import io.fd.jvpp.nat.dto.Nat64BibDetails;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
+import java.util.Optional;
import javax.annotation.Nonnull;
import javax.annotation.concurrent.ThreadSafe;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.naming.context.rev160513.Contexts;
@@ -100,24 +100,24 @@ public class MappingEntryContext implements Ipv4Translator, Ipv6Translator {
private MappingEntryKey entryToKey(final Nat44StaticMappingDetails entry) {
// Only IPv4
return new MappingEntryKey(
- new IpPrefix(new Ipv4Prefix(toIpv4Prefix(entry.externalIpAddress,32))),
- new IpPrefix(new Ipv4Prefix(toIpv4Prefix(entry.localIpAddress, 32))));
+ new IpPrefix(new Ipv4Prefix(toIpv4Prefix(entry.externalIpAddress.ip4Address, 32))),
+ new IpPrefix(new Ipv4Prefix(toIpv4Prefix(entry.localIpAddress.ip4Address, 32))));
}
private MappingEntryKey entryToKey(final Nat64BibDetails entry) {
return new MappingEntryKey(
- new IpPrefix(new Ipv4Prefix(toIpv4Prefix(entry.oAddr, 32))),
- new IpPrefix(new Ipv6Prefix(toIpv6Prefix(entry.iAddr, 128))));
+ new IpPrefix(new Ipv4Prefix(toIpv4Prefix(entry.oAddr.ip4Address, 32))),
+ new IpPrefix(new Ipv6Prefix(toIpv6Prefix(entry.iAddr.ip6Address, 128))));
}
private boolean equalEntries(final Nat44StaticMappingDetails detail, final MappingEntry ctxMappingEntry) {
// Only IPv4
- final IpPrefix internalAddrFromDetails = new IpPrefix(toIpv4Prefix(detail.localIpAddress, 32));
+ final IpPrefix internalAddrFromDetails = new IpPrefix(toIpv4Prefix(detail.localIpAddress.ip4Address, 32));
if (!ctxMappingEntry.getInternal().equals(internalAddrFromDetails)) {
return false;
}
// Only IPv4
- final IpPrefix externalAddrFromDetails = new IpPrefix(toIpv4Prefix(detail.externalIpAddress, 32));
+ final IpPrefix externalAddrFromDetails = new IpPrefix(toIpv4Prefix(detail.externalIpAddress.ip4Address, 32));
if (!ctxMappingEntry.getExternal().equals(externalAddrFromDetails)) {
return false;
}
@@ -126,12 +126,12 @@ public class MappingEntryContext implements Ipv4Translator, Ipv6Translator {
private boolean equalEntries(final Nat64BibDetails detail, final MappingEntry ctxMappingEntry) {
// Only IPv6
- final IpPrefix internalAddrFromDetails = new IpPrefix(toIpv6Prefix(detail.iAddr, 128));
+ final IpPrefix internalAddrFromDetails = new IpPrefix(toIpv6Prefix(detail.iAddr.ip6Address, 128));
if (!ctxMappingEntry.getInternal().equals(internalAddrFromDetails)) {
return false;
}
// Only IPv4
- final IpPrefix externalAddrFromDetails = new IpPrefix(toIpv4Prefix(detail.oAddr, 32));
+ final IpPrefix externalAddrFromDetails = new IpPrefix(toIpv4Prefix(detail.oAddr.ip4Address, 32));
if (!ctxMappingEntry.getExternal().equals(externalAddrFromDetails)) {
return false;
}
diff --git a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/write/ExternalIpPoolCustomizer.java b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/write/ExternalIpPoolCustomizer.java
index 38d2f5a60..8b9d9dd41 100644
--- a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/write/ExternalIpPoolCustomizer.java
+++ b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/write/ExternalIpPoolCustomizer.java
@@ -89,9 +89,9 @@ final class ExternalIpPoolCustomizer implements ListWriterCustomizer<ExternalIpA
final Nat44AddDelAddressRange request = new Nat44AddDelAddressRange();
final Ipv4AddressRange range = Ipv4AddressRange.fromPrefix(externalIpPool);
LOG.trace("Handling NAT44 address range: {}", range);
- request.isAdd = booleanToByte(isAdd);
- request.firstIpAddress = ipv4AddressNoZoneToArray(range.getStart());
- request.lastIpAddress = ipv4AddressNoZoneToArray(range.getEnd());
+ request.isAdd = isAdd;
+ request.firstIpAddress = ipv4AddressNoZoneToNatIp4Address(range.getStart());
+ request.lastIpAddress = ipv4AddressNoZoneToNatIp4Address(range.getEnd());
return request;
}
@@ -99,9 +99,9 @@ final class ExternalIpPoolCustomizer implements ListWriterCustomizer<ExternalIpA
final Nat64AddDelPoolAddrRange request = new Nat64AddDelPoolAddrRange();
final Ipv4AddressRange range = Ipv4AddressRange.fromPrefix(externalIpPool);
LOG.trace("Handling NAT64 address range: {}", range);
- request.isAdd = booleanToByte(isAdd);
- request.startAddr = ipv4AddressNoZoneToArray(range.getStart());
- request.endAddr = ipv4AddressNoZoneToArray(range.getEnd());
+ request.isAdd = isAdd;
+ request.startAddr = ipv4AddressNoZoneToNatIp4Address(range.getStart());
+ request.endAddr = ipv4AddressNoZoneToNatIp4Address(range.getEnd());
return request;
}
}
diff --git a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/write/MappingEntryCustomizer.java b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/write/MappingEntryCustomizer.java
index 9c8da8c84..bf7811852 100644
--- a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/write/MappingEntryCustomizer.java
+++ b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/write/MappingEntryCustomizer.java
@@ -16,7 +16,6 @@
package io.fd.hc2vpp.nat.write;
-import java.util.Optional;
import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
import io.fd.hc2vpp.common.translate.util.Ipv4Translator;
import io.fd.hc2vpp.common.translate.util.Ipv6Translator;
@@ -28,6 +27,9 @@ import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.jvpp.nat.dto.Nat44AddDelStaticMapping;
import io.fd.jvpp.nat.dto.Nat64AddDelStaticBib;
import io.fd.jvpp.nat.future.FutureJVppNatFacade;
+import io.fd.jvpp.nat.types.InterfaceIndex;
+import io.fd.jvpp.nat.types.NatConfigFlags;
+import java.util.Optional;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
@@ -133,15 +135,20 @@ final class MappingEntryCustomizer implements ListWriterCustomizer<MappingEntry,
final boolean isAdd)
throws WriteFailedException.CreateFailedException {
final Nat44AddDelStaticMapping request = new Nat44AddDelStaticMapping();
- request.isAdd = booleanToByte(isAdd);
+ request.isAdd = isAdd;
// VPP uses int, model long
request.vrfId = natInstanceId.intValue();
final Ipv4Prefix internalAddress = mappingEntry.getInternalSrcAddress().getIpv4Prefix();
- request.addrOnly = 1;
- request.localIpAddress = ipv4AddressPrefixToArray(internalAddress);
- request.externalIpAddress = ipv4AddressPrefixToArray(mappingEntry.getExternalSrcAddress().getIpv4Prefix());
- request.externalSwIfIndex = -1; // external ip address is ignored if externalSwIfIndex is given
+ if (request.flags == null) {
+ request.flags = new NatConfigFlags();
+ }
+ request.flags.add(NatConfigFlags.NatConfigFlagsOptions.NAT_IS_ADDR_ONLY);
+ request.localIpAddress = ipv4AddressPrefixToNatIp4Address(internalAddress);
+ request.externalIpAddress =
+ ipv4AddressPrefixToNatIp4Address(mappingEntry.getExternalSrcAddress().getIpv4Prefix());
+ request.externalSwIfIndex = new InterfaceIndex();
+ request.externalSwIfIndex.interfaceindex = -1; // external ip address is ignored if externalSwIfIndex is given
request.protocol = -1;
final Short protocol = mappingEntry.getTransportProtocol();
if (protocol != null) {
@@ -151,7 +158,7 @@ final class MappingEntryCustomizer implements ListWriterCustomizer<MappingEntry,
final Integer internalPortNumber = getPortNumber(mappingEntry.getInternalSrcPort());
final Integer externalPortNumber = getPortNumber(mappingEntry.getExternalSrcPort());
if (internalPortNumber != null && externalPortNumber != null) {
- request.addrOnly = 0;
+ request.flags.remove(NatConfigFlags.NatConfigFlagsOptions.NAT_IS_ADDR_ONLY);
request.localPort = internalPortNumber.shortValue();
request.externalPort = externalPortNumber.shortValue();
}
@@ -164,13 +171,13 @@ final class MappingEntryCustomizer implements ListWriterCustomizer<MappingEntry,
final boolean isAdd)
throws WriteFailedException.CreateFailedException {
final Nat64AddDelStaticBib request = new Nat64AddDelStaticBib();
- request.isAdd = booleanToByte(isAdd);
+ request.isAdd = isAdd;
// VPP uses int, model long
request.vrfId = natInstanceId.intValue();
final Ipv6Prefix internalAddress = mappingEntry.getInternalSrcAddress().getIpv6Prefix();
- request.iAddr = ipv6AddressPrefixToArray(internalAddress);
- request.oAddr = ipv4AddressPrefixToArray(mappingEntry.getExternalSrcAddress().getIpv4Prefix());
+ request.iAddr = ipv6AddressPrefixToNatIp6Address(internalAddress);
+ request.oAddr = ipv4AddressPrefixToNatIp4Address(mappingEntry.getExternalSrcAddress().getIpv4Prefix());
request.proto = -1;
final Short protocol = mappingEntry.getTransportProtocol();
if (protocol != null) {
diff --git a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/write/Nat64PrefixesCustomizer.java b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/write/Nat64PrefixesCustomizer.java
index df8af8550..a9082c0c8 100644
--- a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/write/Nat64PrefixesCustomizer.java
+++ b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/write/Nat64PrefixesCustomizer.java
@@ -76,9 +76,8 @@ final class Nat64PrefixesCustomizer
final Ipv6Prefix nat64Prefix = data.getNat64Prefix();
final Nat64AddDelPrefix request = new Nat64AddDelPrefix();
- request.prefix = ipv6AddressPrefixToArray(nat64Prefix);
- request.prefixLen = extractPrefix(nat64Prefix);
- request.isAdd = booleanToByte(isAdd);
+ request.prefix = ipv6AddressPrefixToNatIp6Prefix(nat64Prefix);
+ request.isAdd = isAdd;
request.vrfId = vrfId;
getReplyForWrite(jvppNat.nat64AddDelPrefix(request).toCompletableFuture(), id);
}
diff --git a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/write/ifc/AbstractInterfaceNatCustomizer.java b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/write/ifc/AbstractInterfaceNatCustomizer.java
index 336b17a6f..380de89a3 100644
--- a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/write/ifc/AbstractInterfaceNatCustomizer.java
+++ b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/write/ifc/AbstractInterfaceNatCustomizer.java
@@ -28,6 +28,8 @@ import io.fd.jvpp.nat.dto.Nat44InterfaceAddDelFeature;
import io.fd.jvpp.nat.dto.Nat44InterfaceAddDelOutputFeature;
import io.fd.jvpp.nat.dto.Nat64AddDelInterface;
import io.fd.jvpp.nat.future.FutureJVppNatFacade;
+import io.fd.jvpp.nat.types.InterfaceIndex;
+import io.fd.jvpp.nat.types.NatConfigFlags;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang._interface.nat.rev170816.InterfaceNatVppFeatureAttributes;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
@@ -89,9 +91,17 @@ abstract class AbstractInterfaceNatCustomizer<D extends InterfaceNatVppFeatureAt
throws WriteFailedException {
checkArgument(!isNat64Supported(natAttributes), "Post routing Nat64 is not supported by VPP");
final Nat44InterfaceAddDelOutputFeature request = new Nat44InterfaceAddDelOutputFeature();
- request.isAdd = booleanToByte(enable);
- request.isInside = getType().isInside;
- request.swIfIndex = ifcIndex;
+ request.isAdd = enable;
+ if (request.flags == null) {
+ request.flags = new NatConfigFlags();
+ }
+ if (getType() == NatType.INBOUND) {
+ request.flags.add(NatConfigFlags.NatConfigFlagsOptions.NAT_IS_INSIDE);
+ } else if (getType() == NatType.OUTBOUND) {
+ request.flags.add(NatConfigFlags.NatConfigFlagsOptions.NAT_IS_OUTSIDE);
+ }
+ request.swIfIndex = new InterfaceIndex();
+ request.swIfIndex.interfaceindex = ifcIndex;
getReplyForWrite(jvppNat.nat44InterfaceAddDelOutputFeature(request).toCompletableFuture(), id);
}
@@ -114,18 +124,34 @@ abstract class AbstractInterfaceNatCustomizer<D extends InterfaceNatVppFeatureAt
private void preRoutingNat44(@Nonnull final InstanceIdentifier<D> id, final int ifcIndex, final boolean enable)
throws WriteFailedException {
final Nat44InterfaceAddDelFeature request = new Nat44InterfaceAddDelFeature();
- request.isAdd = booleanToByte(enable);
- request.isInside = getType().isInside;
- request.swIfIndex = ifcIndex;
+ request.isAdd = enable;
+ if (request.flags == null) {
+ request.flags = new NatConfigFlags();
+ }
+ if (getType() == NatType.INBOUND) {
+ request.flags.add(NatConfigFlags.NatConfigFlagsOptions.NAT_IS_INSIDE);
+ } else if (getType() == NatType.OUTBOUND) {
+ request.flags.add(NatConfigFlags.NatConfigFlagsOptions.NAT_IS_OUTSIDE);
+ }
+ request.swIfIndex = new InterfaceIndex();
+ request.swIfIndex.interfaceindex = ifcIndex;
getReplyForWrite(jvppNat.nat44InterfaceAddDelFeature(request).toCompletableFuture(), id);
}
private void preRoutingNat64(@Nonnull final InstanceIdentifier<D> id, final int ifcIndex, final boolean enable)
throws WriteFailedException {
final Nat64AddDelInterface request = new Nat64AddDelInterface();
- request.isAdd = booleanToByte(enable);
- request.isInside = getType().isInside;
- request.swIfIndex = ifcIndex;
+ request.isAdd = enable;
+ if (request.flags == null) {
+ request.flags = new NatConfigFlags();
+ }
+ if (getType() == NatType.INBOUND) {
+ request.flags.add(NatConfigFlags.NatConfigFlagsOptions.NAT_IS_INSIDE);
+ } else if (getType() == NatType.OUTBOUND) {
+ request.flags.add(NatConfigFlags.NatConfigFlagsOptions.NAT_IS_OUTSIDE);
+ }
+ request.swIfIndex = new InterfaceIndex();
+ request.swIfIndex.interfaceindex = ifcIndex;
getReplyForWrite(jvppNat.nat64AddDelInterface(request).toCompletableFuture(), id);
}
diff --git a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/ExternalIpPoolCustomizerTest.java b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/ExternalIpPoolCustomizerTest.java
index db23b7a24..906572ca0 100644
--- a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/ExternalIpPoolCustomizerTest.java
+++ b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/ExternalIpPoolCustomizerTest.java
@@ -33,6 +33,7 @@ import io.fd.jvpp.nat.dto.Nat44AddressDetailsReplyDump;
import io.fd.jvpp.nat.dto.Nat64PoolAddrDetails;
import io.fd.jvpp.nat.dto.Nat64PoolAddrDetailsReplyDump;
import io.fd.jvpp.nat.future.FutureJVppNatFacade;
+import io.fd.jvpp.nat.types.Ip4Address;
import java.util.Arrays;
import java.util.List;
import java.util.stream.LongStream;
@@ -172,13 +173,16 @@ public class ExternalIpPoolCustomizerTest
Nat44AddressDetailsReplyDump replyDump = dumpReplyNat44Empty();
Nat44AddressDetails detailsOne = new Nat44AddressDetails();
- detailsOne.ipAddress = new byte[]{-64, -88, 44, 1};
+ detailsOne.ipAddress = new Ip4Address();
+ detailsOne.ipAddress.ip4Address = new byte[]{-64, -88, 44, 1};
Nat44AddressDetails detailsTwo = new Nat44AddressDetails();
- detailsTwo.ipAddress = new byte[]{-64, -88, 44, 2};
+ detailsTwo.ipAddress = new Ip4Address();
+ detailsTwo.ipAddress.ip4Address = new byte[]{-64, -88, 44, 2};
Nat44AddressDetails detailsThree = new Nat44AddressDetails();
- detailsThree.ipAddress = new byte[]{-64, -88, 44, 3};
+ detailsThree.ipAddress = new Ip4Address();
+ detailsThree.ipAddress.ip4Address = new byte[]{-64, -88, 44, 3};
replyDump.nat44AddressDetails = Arrays.asList(detailsOne, detailsTwo, detailsThree);
@@ -193,13 +197,16 @@ public class ExternalIpPoolCustomizerTest
Nat64PoolAddrDetailsReplyDump replyDump = dumpReplyNat64Empty();
Nat64PoolAddrDetails detailsOne = new Nat64PoolAddrDetails();
- detailsOne.address = new byte[]{-64, -88, 64, 1};
+ detailsOne.address = new Ip4Address();
+ detailsOne.address.ip4Address = new byte[]{-64, -88, 64, 1};
Nat64PoolAddrDetails detailsTwo = new Nat64PoolAddrDetails();
- detailsTwo.address = new byte[]{-64, -88, 64, 2};
+ detailsTwo.address = new Ip4Address();
+ detailsTwo.address.ip4Address = new byte[]{-64, -88, 64, 2};
Nat64PoolAddrDetails detailsThree = new Nat64PoolAddrDetails();
- detailsThree.address = new byte[]{-64, -88, 64, 3};
+ detailsThree.address = new Ip4Address();
+ detailsThree.address.ip4Address = new byte[]{-64, -88, 64, 3};
replyDump.nat64PoolAddrDetails = Arrays.asList(detailsOne, detailsTwo, detailsThree);
diff --git a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/MappingEntryCustomizerTest.java b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/MappingEntryCustomizerTest.java
index d0541dc24..247c810a8 100644
--- a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/MappingEntryCustomizerTest.java
+++ b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/MappingEntryCustomizerTest.java
@@ -30,6 +30,9 @@ import io.fd.jvpp.nat.dto.Nat44StaticMappingDetails;
import io.fd.jvpp.nat.dto.Nat44StaticMappingDetailsReplyDump;
import io.fd.jvpp.nat.dto.Nat64BibDetails;
import io.fd.jvpp.nat.dto.Nat64BibDetailsReplyDump;
+import io.fd.jvpp.nat.types.Ip4Address;
+import io.fd.jvpp.nat.types.Ip6Address;
+import io.fd.jvpp.nat.types.NatConfigFlags;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
@@ -214,26 +217,33 @@ public class MappingEntryCustomizerTest
Nat44StaticMappingDetailsReplyDump replyDump = new Nat44StaticMappingDetailsReplyDump();
Nat44StaticMappingDetails detailsOne = new Nat44StaticMappingDetails();
- detailsOne.addrOnly = 1;
- detailsOne.localIpAddress = new byte[]{-64, -88, 2, 1};
+ detailsOne.flags = new NatConfigFlags();
+ detailsOne.flags.add(NatConfigFlags.NatConfigFlagsOptions.NAT_IS_ADDR_ONLY);
+ detailsOne.localIpAddress = new Ip4Address();
+ detailsOne.localIpAddress.ip4Address = new byte[]{-64, -88, 2, 1};
detailsOne.localPort = 1234;
- detailsOne.externalIpAddress = new byte[]{-64, -88, 2, 8};
+ detailsOne.externalIpAddress = new Ip4Address();
+ detailsOne.externalIpAddress.ip4Address = new byte[]{-64, -88, 2, 8};
detailsOne.externalPort = 5874;
detailsOne.vrfId = NatInstanceCustomizer.DEFAULT_VRF_ID.getId().byteValue();
Nat44StaticMappingDetails detailsTwo = new Nat44StaticMappingDetails();
- detailsTwo.addrOnly = 0;
- detailsTwo.localIpAddress = new byte[]{-64, -88, 2, 3};
+ detailsTwo.flags = new NatConfigFlags();
+ detailsTwo.localIpAddress = new Ip4Address();
+ detailsTwo.localIpAddress.ip4Address = new byte[]{-64, -88, 2, 3};
detailsTwo.localPort = (short) 60000;
- detailsTwo.externalIpAddress = new byte[]{-64, -88, 2, 5};
+ detailsTwo.externalIpAddress = new Ip4Address();
+ detailsTwo.externalIpAddress.ip4Address = new byte[]{-64, -88, 2, 5};
detailsTwo.externalPort = (short) 65535;
detailsTwo.vrfId = 2;
Nat44StaticMappingDetails detailsThree = new Nat44StaticMappingDetails();
- detailsThree.addrOnly = 0;
- detailsThree.localIpAddress = new byte[]{-64, -88, 2, 2};
+ detailsThree.flags = new NatConfigFlags();
+ detailsThree.localIpAddress = new Ip4Address();
+ detailsThree.localIpAddress.ip4Address = new byte[]{-64, -88, 2, 2};
detailsThree.localPort = 1274;
- detailsThree.externalIpAddress = new byte[]{-64, -88, 3, 8};
+ detailsThree.externalIpAddress = new Ip4Address();
+ detailsThree.externalIpAddress.ip4Address = new byte[]{-64, -88, 3, 8};
detailsThree.externalPort = 6874;
detailsThree.vrfId = NatInstanceCustomizer.DEFAULT_VRF_ID.getId().byteValue();
@@ -245,32 +255,40 @@ public class MappingEntryCustomizerTest
Nat64BibDetailsReplyDump replyDump = new Nat64BibDetailsReplyDump();
Nat64BibDetails detailsOne = new Nat64BibDetails();
- detailsOne.isStatic = 1;
- detailsOne.iAddr =
+ detailsOne.flags = new NatConfigFlags();
+ detailsOne.flags.add(NatConfigFlags.NatConfigFlagsOptions.NAT_IS_STATIC);
+ detailsOne.iAddr = new Ip6Address();
+ detailsOne.iAddr.ip6Address =
new byte[]{0x20, 0x01, 0x0d, (byte) 0xb8, (byte) 0x85, (byte) 0xa3, 0, 0, 0, 0, (byte) 0x8a, 0x2e, 0x03,
0x70, 0x73, 0x01};
detailsOne.iPort = 1234;
- detailsOne.oAddr = new byte[]{-64, -88, 64, 1};
+ detailsOne.oAddr = new Ip4Address();
+ detailsOne.oAddr.ip4Address = new byte[]{-64, -88, 64, 1};
detailsOne.oPort = 5874;
detailsOne.vrfId = NatInstanceCustomizer.DEFAULT_VRF_ID.getId().byteValue();
Nat64BibDetails detailsTwo = new Nat64BibDetails();
- detailsTwo.isStatic = 0;
- detailsTwo.iAddr =
+ detailsTwo.flags = new NatConfigFlags();
+ detailsTwo.iAddr = new Ip6Address();
+ detailsTwo.iAddr.ip6Address =
new byte[]{0x20, 0x01, 0x0d, (byte) 0xb8, (byte) 0x85, (byte) 0xa3, 0, 0, 0, 0, (byte) 0x8a, 0x2e, 0x03,
0x70, 0x73, 0x02};
detailsTwo.iPort = (short) 60000;
- detailsTwo.oAddr = new byte[]{-64, -88, 64, 2};
+ detailsTwo.oAddr = new Ip4Address();
+ detailsTwo.oAddr.ip4Address = new byte[]{-64, -88, 64, 2};
detailsTwo.oPort = (short) 65535;
detailsTwo.vrfId = 2;
Nat64BibDetails detailsThree = new Nat64BibDetails();
- detailsThree.isStatic = 1;
- detailsThree.iAddr =
+ detailsThree.flags = new NatConfigFlags();
+ detailsThree.flags.add(NatConfigFlags.NatConfigFlagsOptions.NAT_IS_STATIC);
+ detailsThree.iAddr = new Ip6Address();
+ detailsThree.iAddr.ip6Address =
new byte[]{0x20, 0x01, 0x0d, (byte) 0xb8, (byte) 0x85, (byte) 0xa3, 0, 0, 0, 0, (byte) 0x8a, 0x2e, 0x03,
0x70, 0x73, 0x03};
detailsThree.iPort = 1274;
- detailsThree.oAddr = new byte[]{-64, -88, 64, 3};
+ detailsThree.oAddr = new Ip4Address();
+ detailsThree.oAddr.ip4Address = new byte[]{-64, -88, 64, 3};
detailsThree.oPort = 6874;
detailsThree.vrfId = NatInstanceCustomizer.DEFAULT_VRF_ID.getId().byteValue();
diff --git a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/Nat64PrefixesCustomizerTest.java b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/Nat64PrefixesCustomizerTest.java
index a3f757389..d576b6037 100644
--- a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/Nat64PrefixesCustomizerTest.java
+++ b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/Nat64PrefixesCustomizerTest.java
@@ -29,6 +29,8 @@ import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.jvpp.nat.dto.Nat64PrefixDetails;
import io.fd.jvpp.nat.dto.Nat64PrefixDetailsReplyDump;
import io.fd.jvpp.nat.future.FutureJVppNatFacade;
+import io.fd.jvpp.nat.types.Ip6Address;
+import io.fd.jvpp.nat.types.Ip6Prefix;
import java.util.List;
import org.junit.Test;
import org.mockito.Mock;
@@ -110,13 +112,18 @@ public class Nat64PrefixesCustomizerTest extends ListReaderCustomizerTest<Nat64P
final Nat64PrefixDetailsReplyDump reply = new Nat64PrefixDetailsReplyDump();
final Nat64PrefixDetails prefix0 = new Nat64PrefixDetails();
prefix0.vrfId = 0;
- prefix0.prefix = new byte[]{0, 0x64, (byte) 0xff, (byte) 0x9b, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
- prefix0.prefixLen = (byte) 96;
+ prefix0.prefix = new Ip6Prefix();
+ prefix0.prefix.prefix = new Ip6Address();
+ prefix0.prefix.prefix.ip6Address =
+ new byte[]{0, 0x64, (byte) 0xff, (byte) 0x9b, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
+ prefix0.prefix.len = (byte) 96;
reply.nat64PrefixDetails.add(prefix0);
final Nat64PrefixDetails prefix1 = new Nat64PrefixDetails();
prefix1.vrfId = 1;
- prefix1.prefix = new byte[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
- prefix1.prefixLen = (byte) 128;
+ prefix1.prefix = new Ip6Prefix();
+ prefix1.prefix.prefix = new Ip6Address();
+ prefix1.prefix.prefix.ip6Address = new byte[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
+ prefix1.prefix.len = (byte) 128;
reply.nat64PrefixDetails.add(prefix1);
return reply;
}
diff --git a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/ifc/InterfaceInboundNatCustomizerTest.java b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/ifc/InterfaceInboundNatCustomizerTest.java
index 8d62782a2..e91741264 100644
--- a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/ifc/InterfaceInboundNatCustomizerTest.java
+++ b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/ifc/InterfaceInboundNatCustomizerTest.java
@@ -34,6 +34,8 @@ import io.fd.jvpp.nat.dto.Nat44InterfaceOutputFeatureDetails;
import io.fd.jvpp.nat.dto.Nat44InterfaceOutputFeatureDetailsReplyDump;
import io.fd.jvpp.nat.dto.Nat64InterfaceDetailsReplyDump;
import io.fd.jvpp.nat.future.FutureJVppNatFacade;
+import io.fd.jvpp.nat.types.InterfaceIndex;
+import io.fd.jvpp.nat.types.NatConfigFlags;
import org.junit.Test;
import org.mockito.Mock;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang._interface.nat.rev170816.NatInterfaceStateAugmentation;
@@ -90,8 +92,10 @@ public class InterfaceInboundNatCustomizerTest
private void mockPostRoutingDump() {
final Nat44InterfaceOutputFeatureDetailsReplyDump details = new Nat44InterfaceOutputFeatureDetailsReplyDump();
final Nat44InterfaceOutputFeatureDetails detail = new Nat44InterfaceOutputFeatureDetails();
- detail.isInside = 1;
- detail.swIfIndex = IFC_IDX;
+ detail.flags = new NatConfigFlags();
+ detail.flags.add(NatConfigFlags.NatConfigFlagsOptions.NAT_IS_INSIDE);
+ detail.swIfIndex = new InterfaceIndex();
+ detail.swIfIndex.interfaceindex = IFC_IDX;
details.nat44InterfaceOutputFeatureDetails = Lists.newArrayList(detail);
when(jvppNat.nat44InterfaceOutputFeatureDump(any())).thenReturn(future(details));
}
@@ -100,8 +104,10 @@ public class InterfaceInboundNatCustomizerTest
public void testPresencePreRouting() throws Exception {
final Nat44InterfaceDetailsReplyDump details = new Nat44InterfaceDetailsReplyDump();
final Nat44InterfaceDetails detail = new Nat44InterfaceDetails();
- detail.isInside = 1;
- detail.swIfIndex = IFC_IDX;
+ detail.flags = new NatConfigFlags();
+ detail.flags.add(NatConfigFlags.NatConfigFlagsOptions.NAT_IS_INSIDE);
+ detail.swIfIndex = new InterfaceIndex();
+ detail.swIfIndex.interfaceindex = IFC_IDX;
details.nat44InterfaceDetails = Lists.newArrayList(detail);
when(jvppNat.nat44InterfaceDump(any())).thenReturn(future(details));
diff --git a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/ifc/InterfaceOutboundNatCustomizerTest.java b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/ifc/InterfaceOutboundNatCustomizerTest.java
index dcf3a3c2b..8bcfd501f 100644
--- a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/ifc/InterfaceOutboundNatCustomizerTest.java
+++ b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/ifc/InterfaceOutboundNatCustomizerTest.java
@@ -35,6 +35,8 @@ import io.fd.jvpp.nat.dto.Nat44InterfaceOutputFeatureDetails;
import io.fd.jvpp.nat.dto.Nat44InterfaceOutputFeatureDetailsReplyDump;
import io.fd.jvpp.nat.dto.Nat64InterfaceDetailsReplyDump;
import io.fd.jvpp.nat.future.FutureJVppNatFacade;
+import io.fd.jvpp.nat.types.InterfaceIndex;
+import io.fd.jvpp.nat.types.NatConfigFlags;
import org.junit.Test;
import org.mockito.Mock;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang._interface.nat.rev170816._interface.nat.attributes.NatBuilder;
@@ -76,8 +78,10 @@ public class InterfaceOutboundNatCustomizerTest
private void mockPostRoutingDump() {
final Nat44InterfaceOutputFeatureDetailsReplyDump details = new Nat44InterfaceOutputFeatureDetailsReplyDump();
final Nat44InterfaceOutputFeatureDetails detail = new Nat44InterfaceOutputFeatureDetails();
- detail.isInside = 0;
- detail.swIfIndex = IFC_IDX;
+ detail.flags = new NatConfigFlags();
+ detail.flags.add(NatConfigFlags.NatConfigFlagsOptions.NAT_IS_OUTSIDE);
+ detail.swIfIndex = new InterfaceIndex();
+ detail.swIfIndex.interfaceindex = IFC_IDX;
details.nat44InterfaceOutputFeatureDetails = Lists.newArrayList(detail);
when(jvppNat.nat44InterfaceOutputFeatureDump(any())).thenReturn(future(details));
}
@@ -86,8 +90,10 @@ public class InterfaceOutboundNatCustomizerTest
public void testPresencePreRouting() throws Exception {
final Nat44InterfaceDetailsReplyDump details = new Nat44InterfaceDetailsReplyDump();
final Nat44InterfaceDetails detail = new Nat44InterfaceDetails();
- detail.isInside = 0;
- detail.swIfIndex = IFC_IDX;
+ detail.flags = new NatConfigFlags();
+ detail.flags.add(NatConfigFlags.NatConfigFlagsOptions.NAT_IS_OUTSIDE);
+ detail.swIfIndex = new InterfaceIndex();
+ detail.swIfIndex.interfaceindex = IFC_IDX;
details.nat44InterfaceDetails = Lists.newArrayList(detail);
when(jvppNat.nat44InterfaceDump(any())).thenReturn(future(details));
diff --git a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/util/MappingEntryContextTest.java b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/util/MappingEntryContextTest.java
index 86abf0e27..fdfec0211 100644
--- a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/util/MappingEntryContextTest.java
+++ b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/util/MappingEntryContextTest.java
@@ -24,18 +24,20 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
-import java.util.Optional;
import com.google.common.collect.Lists;
import io.fd.hc2vpp.common.translate.util.Ipv4Translator;
import io.fd.honeycomb.translate.MappingContext;
import io.fd.jvpp.nat.dto.Nat44StaticMappingDetails;
+import io.fd.jvpp.nat.types.NatConfigFlags;
import java.util.Collections;
import java.util.List;
+import java.util.Optional;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.nat.context.rev161214.mapping.entry.context.attributes.nat.mapping.entry.context.nat.instance.MappingTableBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.nat.rev180628.nat.instances.instance.mapping.table.MappingEntry;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.nat.rev180628.nat.instances.instance.mapping.table.MappingEntryBuilder;
@@ -168,9 +170,10 @@ public class MappingEntryContextTest implements Ipv4Translator {
private Nat44StaticMappingDetails getDetails(final long vrfId, final String localIp, final String externIp) {
final Nat44StaticMappingDetails nat44StaticMappingDetails = new Nat44StaticMappingDetails();
nat44StaticMappingDetails.vrfId = (int) vrfId;
- nat44StaticMappingDetails.addrOnly = 1;
- nat44StaticMappingDetails.localIpAddress = ipv4AddressNoZoneToArray(localIp);
- nat44StaticMappingDetails.externalIpAddress = ipv4AddressNoZoneToArray(externIp);
+ nat44StaticMappingDetails.flags = new NatConfigFlags();
+ nat44StaticMappingDetails.flags.add(NatConfigFlags.NatConfigFlagsOptions.NAT_IS_ADDR_ONLY);
+ nat44StaticMappingDetails.localIpAddress = ipv4AddressNoZoneToNatIp4Address(new Ipv4AddressNoZone(localIp));
+ nat44StaticMappingDetails.externalIpAddress = ipv4AddressNoZoneToNatIp4Address(new Ipv4AddressNoZone(externIp));
return nat44StaticMappingDetails;
}
diff --git a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/ExternalIpPoolCustomizerTest.java b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/ExternalIpPoolCustomizerTest.java
index 9da83bf76..0ad81977f 100644
--- a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/ExternalIpPoolCustomizerTest.java
+++ b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/ExternalIpPoolCustomizerTest.java
@@ -33,6 +33,7 @@ import io.fd.jvpp.nat.dto.Nat44AddDelAddressRangeReply;
import io.fd.jvpp.nat.dto.Nat64AddDelPoolAddrRange;
import io.fd.jvpp.nat.dto.Nat64AddDelPoolAddrRangeReply;
import io.fd.jvpp.nat.future.FutureJVppNatFacade;
+import io.fd.jvpp.nat.types.Ip4Address;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -117,17 +118,21 @@ public class ExternalIpPoolCustomizerTest extends WriterCustomizerTest implement
private Nat44AddDelAddressRange getExpectedRequestNat44(final boolean isAdd) {
final Nat44AddDelAddressRange expectedRequest = new Nat44AddDelAddressRange();
- expectedRequest.isAdd = booleanToByte(isAdd);
- expectedRequest.firstIpAddress = new byte[] {(byte) 192, (byte) 168, 1, 0};
- expectedRequest.lastIpAddress = new byte[] {(byte) 192, (byte) 168, 1, (byte) 255};
+ expectedRequest.isAdd = isAdd;
+ expectedRequest.firstIpAddress = new Ip4Address();
+ expectedRequest.firstIpAddress.ip4Address = new byte[]{(byte) 192, (byte) 168, 1, 0};
+ expectedRequest.lastIpAddress = new Ip4Address();
+ expectedRequest.lastIpAddress.ip4Address = new byte[]{(byte) 192, (byte) 168, 1, (byte) 255};
return expectedRequest;
}
private Nat64AddDelPoolAddrRange getExpectedRequestNat64(final boolean isAdd) {
final Nat64AddDelPoolAddrRange expectedRequest = new Nat64AddDelPoolAddrRange();
- expectedRequest.isAdd = booleanToByte(isAdd);
- expectedRequest.startAddr = new byte[] {(byte) 192, (byte) 168, 1, 0};
- expectedRequest.endAddr = new byte[] {(byte) 192, (byte) 168, 1, (byte) 255};
+ expectedRequest.isAdd = isAdd;
+ expectedRequest.startAddr = new Ip4Address();
+ expectedRequest.startAddr.ip4Address = new byte[]{(byte) 192, (byte) 168, 1, 0};
+ expectedRequest.endAddr = new Ip4Address();
+ expectedRequest.endAddr.ip4Address = new byte[]{(byte) 192, (byte) 168, 1, (byte) 255};
return expectedRequest;
}
} \ No newline at end of file
diff --git a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/MappingEntryCustomizerTest.java b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/MappingEntryCustomizerTest.java
index 129fb8f2c..d67552b4a 100644
--- a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/MappingEntryCustomizerTest.java
+++ b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/MappingEntryCustomizerTest.java
@@ -32,6 +32,10 @@ import io.fd.jvpp.nat.dto.Nat44AddDelStaticMappingReply;
import io.fd.jvpp.nat.dto.Nat64AddDelStaticBib;
import io.fd.jvpp.nat.dto.Nat64AddDelStaticBibReply;
import io.fd.jvpp.nat.future.FutureJVppNatFacade;
+import io.fd.jvpp.nat.types.InterfaceIndex;
+import io.fd.jvpp.nat.types.Ip4Address;
+import io.fd.jvpp.nat.types.Ip6Address;
+import io.fd.jvpp.nat.types.NatConfigFlags;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -73,7 +77,7 @@ public class MappingEntryCustomizerTest extends WriterCustomizerTest implements
throws WriteFailedException {
customizer.writeCurrentAttributes(IID, extractMappingEntry(data), writeContext);
final Nat44AddDelStaticMapping expectedRequest = getExpectedNat44Request();
- expectedRequest.isAdd = 1;
+ expectedRequest.isAdd = true;
verify(jvppNat).nat44AddDelStaticMapping(expectedRequest);
}
@@ -83,7 +87,7 @@ public class MappingEntryCustomizerTest extends WriterCustomizerTest implements
throws WriteFailedException {
customizer.writeCurrentAttributes(IID, extractMappingEntry(data), writeContext);
final Nat64AddDelStaticBib expectedRequest = getExpectedNat64Request();
- expectedRequest.isAdd = 1;
+ expectedRequest.isAdd = true;
verify(jvppNat).nat64AddDelStaticBib(expectedRequest);
}
@@ -96,7 +100,7 @@ public class MappingEntryCustomizerTest extends WriterCustomizerTest implements
final Nat64AddDelStaticBib expectedDeleteRequest = getExpectedNat64Request();
verify(jvppNat).nat64AddDelStaticBib(expectedDeleteRequest);
final Nat64AddDelStaticBib expectedUpdateRequest = getExpectedNat64UpdateRequest();
- expectedUpdateRequest.isAdd = 1;
+ expectedUpdateRequest.isAdd = true;
verify(jvppNat).nat64AddDelStaticBib(expectedUpdateRequest);
}
@@ -123,12 +127,16 @@ public class MappingEntryCustomizerTest extends WriterCustomizerTest implements
private static Nat44AddDelStaticMapping getExpectedNat44Request() {
final Nat44AddDelStaticMapping expectedRequest = new Nat44AddDelStaticMapping();
- expectedRequest.addrOnly = 1;
+ expectedRequest.flags = new NatConfigFlags();
+ expectedRequest.flags.add(NatConfigFlags.NatConfigFlagsOptions.NAT_IS_ADDR_ONLY);
expectedRequest.protocol = 17; // udp
expectedRequest.vrfId = (int) NAT_INSTANCE_ID;
- expectedRequest.externalSwIfIndex = -1;
- expectedRequest.localIpAddress = new byte[] {(byte) 192, (byte) 168, 1, 87};
- expectedRequest.externalIpAddress = new byte[] {45, 1, 5, 7};
+ expectedRequest.externalSwIfIndex = new InterfaceIndex();
+ expectedRequest.externalSwIfIndex.interfaceindex = -1;
+ expectedRequest.localIpAddress = new Ip4Address();
+ expectedRequest.localIpAddress.ip4Address = new byte[]{(byte) 192, (byte) 168, 1, 87};
+ expectedRequest.externalIpAddress = new Ip4Address();
+ expectedRequest.externalIpAddress.ip4Address = new byte[]{45, 1, 5, 7};
return expectedRequest;
}
@@ -136,21 +144,29 @@ public class MappingEntryCustomizerTest extends WriterCustomizerTest implements
final Nat64AddDelStaticBib expectedRequest = new Nat64AddDelStaticBib();
expectedRequest.proto = 58; // icmp v6
expectedRequest.vrfId = (int) NAT_INSTANCE_ID;
- expectedRequest.iAddr = new byte[] {0x20, 0x01, 0x0d, (byte) 0xb8, (byte) 0x85, (byte) 0xa3, 0, 0, 0, 0, (byte) 0x8a, 0x2e, 0x03, 0x70, 0x73, 0x33};
+ expectedRequest.iAddr = new Ip6Address();
+ expectedRequest.iAddr.ip6Address =
+ new byte[]{0x20, 0x01, 0x0d, (byte) 0xb8, (byte) 0x85, (byte) 0xa3, 0, 0, 0, 0, (byte) 0x8a, 0x2e, 0x03,
+ 0x70, 0x73, 0x33};
expectedRequest.iPort = 123;
- expectedRequest.oAddr = new byte[] {10, 1, 1, 3};
+ expectedRequest.oAddr = new Ip4Address();
+ expectedRequest.oAddr.ip4Address = new byte[]{10, 1, 1, 3};
expectedRequest.oPort = 456;
return expectedRequest;
}
private static Nat44AddDelStaticMapping getExpectedNat44UpdateRequest() {
final Nat44AddDelStaticMapping expectedRequest = new Nat44AddDelStaticMapping();
- expectedRequest.addrOnly = 1;
+ expectedRequest.flags = new NatConfigFlags();
+ expectedRequest.flags.add(NatConfigFlags.NatConfigFlagsOptions.NAT_IS_ADDR_ONLY);
expectedRequest.protocol = 17; // udp
expectedRequest.vrfId = (int) NAT_INSTANCE_ID;
- expectedRequest.externalSwIfIndex = -1;
- expectedRequest.localIpAddress = new byte[] {(byte) 192, (byte) 168, 1, 86};
- expectedRequest.externalIpAddress = new byte[] {45, 1, 5, 6};
+ expectedRequest.externalSwIfIndex = new InterfaceIndex();
+ expectedRequest.externalSwIfIndex.interfaceindex = -1;
+ expectedRequest.localIpAddress = new Ip4Address();
+ expectedRequest.localIpAddress.ip4Address = new byte[]{(byte) 192, (byte) 168, 1, 86};
+ expectedRequest.externalIpAddress = new Ip4Address();
+ expectedRequest.externalIpAddress.ip4Address = new byte[]{45, 1, 5, 6};
return expectedRequest;
}
@@ -158,8 +174,12 @@ public class MappingEntryCustomizerTest extends WriterCustomizerTest implements
final Nat64AddDelStaticBib expectedRequest = new Nat64AddDelStaticBib();
expectedRequest.proto = 58; // icmp v6
expectedRequest.vrfId = (int) NAT_INSTANCE_ID;
- expectedRequest.iAddr = new byte[] {0x20, 0x01, 0x0d, (byte) 0xb8, (byte) 0x85, (byte) 0xa3, 0, 0, 0, 0, (byte) 0x8a, 0x2e, 0x03, 0x70, 0x73, 0x34};
- expectedRequest.oAddr = new byte[] {10, 1, 1, 4};
+ expectedRequest.iAddr = new Ip6Address();
+ expectedRequest.iAddr.ip6Address =
+ new byte[]{0x20, 0x01, 0x0d, (byte) 0xb8, (byte) 0x85, (byte) 0xa3, 0, 0, 0, 0, (byte) 0x8a, 0x2e, 0x03,
+ 0x70, 0x73, 0x34};
+ expectedRequest.oAddr = new Ip4Address();
+ expectedRequest.oAddr.ip4Address = new byte[]{10, 1, 1, 4};
expectedRequest.iPort = 1234;
expectedRequest.oPort = 5678;
return expectedRequest;
diff --git a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/Nat64PrefixesCustomizerTest.java b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/Nat64PrefixesCustomizerTest.java
index b16de9032..079b2056b 100644
--- a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/Nat64PrefixesCustomizerTest.java
+++ b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/Nat64PrefixesCustomizerTest.java
@@ -26,6 +26,8 @@ import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
import io.fd.jvpp.nat.dto.Nat64AddDelPrefix;
import io.fd.jvpp.nat.dto.Nat64AddDelPrefixReply;
import io.fd.jvpp.nat.future.FutureJVppNatFacade;
+import io.fd.jvpp.nat.types.Ip6Address;
+import io.fd.jvpp.nat.types.Ip6Prefix;
import org.junit.Test;
import org.mockito.Mock;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix;
@@ -77,10 +79,13 @@ public class Nat64PrefixesCustomizerTest extends WriterCustomizerTest implements
private Nat64AddDelPrefix expectedRequest(final boolean isAdd) {
final Nat64AddDelPrefix request = new Nat64AddDelPrefix();
- request.isAdd = booleanToByte(isAdd);
+ request.isAdd = isAdd;
request.vrfId = (int) VRF_ID;
- request.prefix = new byte[]{0x20, 0x01, 0x0d, (byte) 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- request.prefixLen = 32;
+ request.prefix = new Ip6Prefix();
+ request.prefix.prefix = new Ip6Address();
+ request.prefix.prefix.ip6Address =
+ new byte[]{0x20, 0x01, 0x0d, (byte) 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ request.prefix.len = 32;
return request;
}
} \ No newline at end of file
diff --git a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/ifc/AbstractNatCustomizerTest.java b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/ifc/AbstractNatCustomizerTest.java
index 52eeb82a3..c2ea5b676 100644
--- a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/ifc/AbstractNatCustomizerTest.java
+++ b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/ifc/AbstractNatCustomizerTest.java
@@ -31,10 +31,13 @@ import io.fd.jvpp.nat.dto.Nat44InterfaceAddDelOutputFeatureReply;
import io.fd.jvpp.nat.dto.Nat64AddDelInterface;
import io.fd.jvpp.nat.dto.Nat64AddDelInterfaceReply;
import io.fd.jvpp.nat.future.FutureJVppNatFacade;
+import io.fd.jvpp.nat.types.InterfaceIndex;
+import io.fd.jvpp.nat.types.NatConfigFlags;
import org.junit.Test;
import org.mockito.Mock;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang._interface.nat.rev170816.InterfaceNatVppFeatureAttributes;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang._interface.nat.rev170816._interface.nat.attributes.nat.Inbound;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang._interface.nat.rev170816._interface.nat.attributes.nat.Outbound;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@@ -118,25 +121,43 @@ abstract class AbstractNatCustomizerTest<D extends InterfaceNatVppFeatureAttribu
private Nat44InterfaceAddDelFeature expectedPreRoutingNat44Request(final D data, boolean isAdd) {
Nat44InterfaceAddDelFeature request = new Nat44InterfaceAddDelFeature();
- request.isInside = booleanToByte(data instanceof Inbound);
- request.swIfIndex = IFACE_ID;
- request.isAdd = booleanToByte(isAdd);
+ request.flags = new NatConfigFlags();
+ if (data instanceof Inbound) {
+ request.flags.add(NatConfigFlags.NatConfigFlagsOptions.NAT_IS_INSIDE);
+ } else if (data instanceof Outbound) {
+ request.flags.add(NatConfigFlags.NatConfigFlagsOptions.NAT_IS_OUTSIDE);
+ }
+ request.swIfIndex = new InterfaceIndex();
+ request.swIfIndex.interfaceindex = IFACE_ID;
+ request.isAdd = isAdd;
return request;
}
private Nat64AddDelInterface expectedPreRoutingNat64Request(final D data, boolean isAdd) {
Nat64AddDelInterface request = new Nat64AddDelInterface();
- request.isInside = booleanToByte(data instanceof Inbound);
- request.swIfIndex = IFACE_ID;
- request.isAdd = booleanToByte(isAdd);
+ request.flags = new NatConfigFlags();
+ if (data instanceof Inbound) {
+ request.flags.add(NatConfigFlags.NatConfigFlagsOptions.NAT_IS_INSIDE);
+ } else if (data instanceof Outbound) {
+ request.flags.add(NatConfigFlags.NatConfigFlagsOptions.NAT_IS_OUTSIDE);
+ }
+ request.swIfIndex = new InterfaceIndex();
+ request.swIfIndex.interfaceindex = IFACE_ID;
+ request.isAdd = isAdd;
return request;
}
private Nat44InterfaceAddDelOutputFeature expectedPostRoutingRequest(final D data, boolean isAdd) {
Nat44InterfaceAddDelOutputFeature request = new Nat44InterfaceAddDelOutputFeature();
- request.isInside = booleanToByte(data instanceof Inbound);
- request.swIfIndex = IFACE_ID;
- request.isAdd = booleanToByte(isAdd);
+ request.flags = new NatConfigFlags();
+ if (data instanceof Inbound) {
+ request.flags.add(NatConfigFlags.NatConfigFlagsOptions.NAT_IS_INSIDE);
+ } else if (data instanceof Outbound) {
+ request.flags.add(NatConfigFlags.NatConfigFlagsOptions.NAT_IS_OUTSIDE);
+ }
+ request.swIfIndex = new InterfaceIndex();
+ request.swIfIndex.interfaceindex = IFACE_ID;
+ request.isAdd = isAdd;
return request;
}