summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nat/nat-api/src/main/yang/ietf-nat@2018-02-23.yang12
-rw-r--r--nat/nat-api/src/main/yang/nat-context@2016-12-14.yang4
-rw-r--r--nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/MappingEntryCustomizer.java12
-rw-r--r--nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/util/MappingEntryContext.java25
-rw-r--r--nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/write/MappingEntryCustomizer.java47
-rw-r--r--nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/MappingEntryCustomizerTest.java8
-rw-r--r--nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/util/MappingEntryContextTest.java32
-rw-r--r--nat/nat2vpp/src/test/resources/nat44/static-mapping-address-update.json4
-rw-r--r--nat/nat2vpp/src/test/resources/nat44/static-mapping-unsupported-proto.json4
-rw-r--r--nat/nat2vpp/src/test/resources/nat44/static-mapping.json4
-rw-r--r--nat/nat2vpp/src/test/resources/nat64/static-mapping-address-update.json4
-rw-r--r--nat/nat2vpp/src/test/resources/nat64/static-mapping-unsupported-proto.json4
-rw-r--r--nat/nat2vpp/src/test/resources/nat64/static-mapping.json4
-rw-r--r--nat/nat_postman_collection.json7
14 files changed, 87 insertions, 84 deletions
diff --git a/nat/nat-api/src/main/yang/ietf-nat@2018-02-23.yang b/nat/nat-api/src/main/yang/ietf-nat@2018-02-23.yang
index 77e2d7be7..5eec4c609 100644
--- a/nat/nat-api/src/main/yang/ietf-nat@2018-02-23.yang
+++ b/nat/nat-api/src/main/yang/ietf-nat@2018-02-23.yang
@@ -420,8 +420,7 @@ module ietf-nat {
}
leaf internal-src-address {
- // TODO(HC2VPP-325): original model uses inet:ip-prefix;
- type inet:ip-address;
+ type inet:ip-prefix;
description
"Corresponds to the source IPv4/IPv6 address/prefix
of the packet received on an internal
@@ -444,8 +443,7 @@ module ietf-nat {
}
leaf external-src-address {
- // TODO(HC2VPP-325): original model uses inet:ip-prefix;
- type inet:ipv4-address;
+ type inet:ip-prefix;
description
"Source IP address/prefix of the packet sent on an
external interface of the NAT.";
@@ -462,8 +460,7 @@ module ietf-nat {
}
leaf internal-dst-address {
- // TODO(HC2VPP-325): original model uses inet:ip-prefix;
- type inet:ipv4-prefix;
+ type inet:ip-prefix;
description
"Corresponds to the destination IP address/prefix
of the packet received on an internal interface
@@ -487,8 +484,7 @@ module ietf-nat {
}
leaf external-dst-address {
- // TODO(HC2VPP-325): original model uses inet:ip-prefix;
- type inet:ipv4-address;
+ type inet:ip-prefix;
description
"Corresponds to the destination IP address/prefix
of the packet sent on an external interface
diff --git a/nat/nat-api/src/main/yang/nat-context@2016-12-14.yang b/nat/nat-api/src/main/yang/nat-context@2016-12-14.yang
index de9436878..a99e65f17 100644
--- a/nat/nat-api/src/main/yang/nat-context@2016-12-14.yang
+++ b/nat/nat-api/src/main/yang/nat-context@2016-12-14.yang
@@ -65,12 +65,12 @@ module nat-context {
unique "index";
leaf internal {
- type inet:ip-address;
+ type inet:ip-prefix;
description "Local IP address set in VPP";
}
leaf external {
- type inet:ip-address;
+ type inet:ip-prefix;
description "Extarnal IP address set in VPP";
}
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 43dba092a..15f73e66f 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
@@ -37,7 +37,7 @@ import java.util.List;
import java.util.Optional;
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.IpAddress;
+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.PortNumber;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.nat.rev180223.mapping.entry.ExternalSrcPortBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.nat.rev180223.mapping.entry.InternalSrcPortBuilder;
@@ -114,9 +114,8 @@ 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.rev180223.MappingEntry.Type.Static);
- builder.setExternalSrcAddress(arrayToIpv4AddressNoZone(detail.externalIpAddress));
- builder.setInternalSrcAddress(
- new IpAddress(arrayToIpv4AddressNoZone(detail.localIpAddress)));
+ builder.setExternalSrcAddress(new IpPrefix(toIpv4Prefix(detail.externalIpAddress, 32)));
+ builder.setInternalSrcAddress(new IpPrefix(toIpv4Prefix(detail.localIpAddress, 32)));
if (detail.addrOnly == 0) {
builder.setExternalSrcPort(new ExternalSrcPortBuilder()
@@ -136,9 +135,8 @@ final class MappingEntryCustomizer implements Ipv4Translator, Ipv6Translator,
builder.setType(
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.nat.rev180223.MappingEntry.Type.DynamicImplicit);
}
- builder.setExternalSrcAddress(arrayToIpv4AddressNoZone(detail.oAddr));
- builder.setInternalSrcAddress(
- new IpAddress(arrayToIpv6AddressNoZone(detail.iAddr)));
+ builder.setExternalSrcAddress(new IpPrefix(toIpv4Prefix(detail.oAddr,32 )));
+ builder.setInternalSrcAddress(new IpPrefix(toIpv6Prefix(detail.iAddr, 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/util/MappingEntryContext.java b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/util/MappingEntryContext.java
index 0f7220988..d136764d0 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
@@ -40,8 +40,11 @@ import org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.nat.context
import org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.nat.context.rev161214.mapping.entry.context.attributes.nat.mapping.entry.context.nat.instance.mapping.table.MappingEntryBuilder;
import org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.nat.context.rev161214.mapping.entry.context.attributes.nat.mapping.entry.context.nat.instance.mapping.table.MappingEntryKey;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
+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.Ipv4Address;
+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.inet.types.rev130715.Ipv6Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -94,32 +97,30 @@ public class MappingEntryContext implements Ipv4Translator, Ipv6Translator {
static MappingEntryKey entryToKey(
final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.nat.rev180223.nat.instances.instance.mapping.table.MappingEntry entry) {
// Only IPv4
- return new MappingEntryKey(new IpAddress(entry.getExternalSrcAddress()), entry.getInternalSrcAddress());
+ return new MappingEntryKey(entry.getExternalSrcAddress(), entry.getInternalSrcAddress());
}
private MappingEntryKey entryToKey(final Nat44StaticMappingDetails entry) {
// Only IPv4
return new MappingEntryKey(
- new IpAddress(new Ipv4Address(arrayToIpv4AddressNoZone(entry.externalIpAddress))),
- new IpAddress(new Ipv4Address(arrayToIpv4AddressNoZone(entry.localIpAddress))));
+ new IpPrefix(new Ipv4Prefix(toIpv4Prefix(entry.externalIpAddress,32))),
+ new IpPrefix(new Ipv4Prefix(toIpv4Prefix(entry.localIpAddress, 32))));
}
private MappingEntryKey entryToKey(final Nat64BibDetails entry) {
return new MappingEntryKey(
- new IpAddress(new Ipv4Address(arrayToIpv4AddressNoZone(entry.oAddr))),
- new IpAddress(new Ipv6Address(arrayToIpv6AddressNoZone(entry.iAddr))));
+ new IpPrefix(new Ipv4Prefix(toIpv4Prefix(entry.oAddr, 32))),
+ new IpPrefix(new Ipv6Prefix(toIpv6Prefix(entry.iAddr, 128))));
}
private boolean equalEntries(final Nat44StaticMappingDetails detail, final MappingEntry ctxMappingEntry) {
- final IpAddress internalAddrFromDetails =
- new IpAddress(new Ipv4Address(arrayToIpv4AddressNoZone(detail.localIpAddress)));
// Only IPv4
+ final IpPrefix internalAddrFromDetails = new IpPrefix(toIpv4Prefix(detail.localIpAddress, 32));
if (!ctxMappingEntry.getInternal().equals(internalAddrFromDetails)) {
return false;
}
// Only IPv4
- final IpAddress externalAddrFromDetails =
- new IpAddress(new Ipv4Address(arrayToIpv4AddressNoZone(detail.externalIpAddress)));
+ final IpPrefix externalAddrFromDetails = new IpPrefix(toIpv4Prefix(detail.externalIpAddress, 32));
if (!ctxMappingEntry.getExternal().equals(externalAddrFromDetails)) {
return false;
}
@@ -127,15 +128,13 @@ public class MappingEntryContext implements Ipv4Translator, Ipv6Translator {
}
private boolean equalEntries(final Nat64BibDetails detail, final MappingEntry ctxMappingEntry) {
- final IpAddress internalAddrFromDetails =
- new IpAddress(new Ipv6Address(arrayToIpv6AddressNoZone(detail.iAddr)));
// Only IPv6
+ final IpPrefix internalAddrFromDetails = new IpPrefix(toIpv6Prefix(detail.iAddr, 128));
if (!ctxMappingEntry.getInternal().equals(internalAddrFromDetails)) {
return false;
}
// Only IPv4
- final IpAddress externalAddrFromDetails =
- new IpAddress(new Ipv4Address(arrayToIpv4AddressNoZone(detail.oAddr)));
+ final IpPrefix externalAddrFromDetails = new IpPrefix(toIpv4Prefix(detail.oAddr, 32));
if (!ctxMappingEntry.getExternal().equals(externalAddrFromDetails)) {
return false;
}
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 6aca1af9e..74160683b 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
@@ -32,9 +32,9 @@ import io.fd.vpp.jvpp.nat.dto.Nat44AddDelStaticMapping;
import io.fd.vpp.jvpp.nat.dto.Nat64AddDelStaticBib;
import io.fd.vpp.jvpp.nat.future.FutureJVppNatFacade;
import javax.annotation.Nonnull;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
+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;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.nat.rev180223.PortNumber;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.nat.rev180223.nat.instances.Instance;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.nat.rev180223.nat.instances.instance.mapping.table.MappingEntry;
@@ -85,15 +85,15 @@ final class MappingEntryCustomizer implements ListWriterCustomizer<MappingEntry,
@Nonnull final MappingEntry entry,
@Nonnull final Long natInstanceId,
final boolean isAdd) throws WriteFailedException {
- final IpAddress internalSrcAddress = entry.getInternalSrcAddress();
- final Ipv4Address internalV4SrcAddress = internalSrcAddress.getIpv4Address();
- final Ipv6Address internalV6SrcAddress = internalSrcAddress.getIpv6Address();
- if (internalV4SrcAddress != null) {
+ final IpPrefix internalSrcPrefix = entry.getInternalSrcAddress();
+ final Ipv4Prefix internalV4SrcPrefix = internalSrcPrefix.getIpv4Prefix();
+ final Ipv6Prefix internalV6SrcPrefix = internalSrcPrefix.getIpv6Prefix();
+ if (internalV4SrcPrefix != null) {
final Nat44AddDelStaticMapping request = getNat44Request(id, entry, natInstanceId, isAdd);
getReplyForWrite(jvppNat.nat44AddDelStaticMapping(request).toCompletableFuture(), id);
} else {
- checkState(internalV6SrcAddress != null,
- "internalSrcAddress.getIpv6Address() should not return null if v4 address is not given");
+ checkState(internalV6SrcPrefix != null,
+ "internalSrcPrefix.getIpv4Prefix() should not return null if v4 prefix is not given");
final Nat64AddDelStaticBib request = getNat64Request(id, entry, natInstanceId, isAdd);
getReplyForWrite(jvppNat.nat64AddDelStaticBib(request).toCompletableFuture(), id);
}
@@ -147,14 +147,15 @@ final class MappingEntryCustomizer implements ListWriterCustomizer<MappingEntry,
// VPP uses int, model long
request.vrfId = natInstanceId.intValue();
- final Ipv4Address internalAddress = mappingEntry.getInternalSrcAddress().getIpv4Address();
+ final Ipv4Prefix internalAddress = mappingEntry.getInternalSrcAddress().getIpv4Prefix();
checkArgument(internalAddress != null, "No Ipv4 present in internal-src-address %s",
- mappingEntry.getInternalSrcAddress());
+ mappingEntry.getInternalSrcAddress());
+ checkArgument(extractPrefix(internalAddress) == 32,
+ "Only /32 prefix in internal-src-address is supported, but was %s", internalAddress);
request.addrOnly = 1;
- request.localIpAddress =
- ipv4AddressNoZoneToArray(mappingEntry.getInternalSrcAddress().getIpv4Address().getValue());
- request.externalIpAddress = ipv4AddressNoZoneToArray(mappingEntry.getExternalSrcAddress().getValue());
+ request.localIpAddress = ipv4AddressPrefixToArray(internalAddress);
+ request.externalIpAddress = ipv4AddressPrefixToArray(getExternalAddress(mappingEntry));
request.externalSwIfIndex = -1; // external ip address is ignored if externalSwIfIndex is given
request.protocol = -1;
final Short protocol = mappingEntry.getTransportProtocol();
@@ -185,13 +186,14 @@ final class MappingEntryCustomizer implements ListWriterCustomizer<MappingEntry,
// VPP uses int, model long
request.vrfId = natInstanceId.intValue();
- final Ipv6Address internalAddress = mappingEntry.getInternalSrcAddress().getIpv6Address();
+ final Ipv6Prefix internalAddress = mappingEntry.getInternalSrcAddress().getIpv6Prefix();
checkArgument(internalAddress != null, "No Ipv6 present in internal-src-address %s",
mappingEntry.getInternalSrcAddress());
+ checkArgument(extractPrefix(internalAddress) == (byte)128,
+ "Only /128 prefix in internal-src-address is supported, but was %s", internalAddress);
-
- request.iAddr = ipv6AddressNoZoneToArray(internalAddress);
- request.oAddr = ipv4AddressNoZoneToArray(mappingEntry.getExternalSrcAddress().getValue());
+ request.iAddr = ipv6AddressPrefixToArray(internalAddress);
+ request.oAddr = ipv4AddressPrefixToArray(getExternalAddress(mappingEntry));
request.proto = -1;
final Short protocol = mappingEntry.getTransportProtocol();
if (protocol != null) {
@@ -210,6 +212,15 @@ final class MappingEntryCustomizer implements ListWriterCustomizer<MappingEntry,
return request;
}
+ private Ipv4Prefix getExternalAddress(final MappingEntry mappingEntry) {
+ final Ipv4Prefix externalAddress = mappingEntry.getExternalSrcAddress().getIpv4Prefix();
+ checkArgument(externalAddress != null, "No Ipv4 present in external-src-address %s",
+ mappingEntry.getExternalSrcAddress());
+ checkArgument(extractPrefix(externalAddress) == 32,
+ "Only /32 prefix in external-src-address is supported, but was %s", externalAddress);
+ return externalAddress;
+ }
+
private Short getPortNumber(final InstanceIdentifier<MappingEntry> id, final PortNumber portNumber) {
if (portNumber != null) {
if (portNumber.getStartPortNumber() != null && portNumber.getEndPortNumber() == null) {
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 7f38dc9b9..9ce42dafe 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
@@ -98,9 +98,9 @@ public class MappingEntryCustomizerTest
getCustomizer().readCurrentAttributes(mappingEntryId, builder, ctx);
assertEquals(NAT_MAPPING_ID, builder.getIndex().longValue());
- assertEquals("192.168.3.8", builder.getExternalSrcAddress().getValue());
+ assertEquals("192.168.3.8/32", builder.getExternalSrcAddress().getIpv4Prefix().getValue());
assertEquals(6874, builder.getExternalSrcPort().getStartPortNumber().getValue().intValue());
- assertArrayEquals("192.168.2.2".toCharArray(), builder.getInternalSrcAddress().getValue());
+ assertEquals("192.168.2.2/32", builder.getInternalSrcAddress().getIpv4Prefix().getValue());
assertEquals(1274, builder.getInternalSrcPort().getStartPortNumber().getValue().intValue());
}
@@ -128,9 +128,9 @@ public class MappingEntryCustomizerTest
getCustomizer().readCurrentAttributes(mappingEntryId, builder, ctx);
assertEquals(NAT_MAPPING_ID, builder.getIndex().longValue());
- assertEquals("192.168.64.3", builder.getExternalSrcAddress().getValue());
+ assertEquals("192.168.64.3/32", builder.getExternalSrcAddress().getIpv4Prefix().getValue());
assertEquals(6874, builder.getExternalSrcPort().getStartPortNumber().getValue().intValue());
- assertArrayEquals("2001:db8:85a3::8a2e:370:7303".toCharArray(), builder.getInternalSrcAddress().getValue());
+ assertEquals("2001:db8:85a3::8a2e:370:7303/128", builder.getInternalSrcAddress().getIpv6Prefix().getValue());
assertEquals(1274, builder.getInternalSrcPort().getStartPortNumber().getValue().intValue());
}
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 df5912bce..3af318c3e 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
@@ -26,8 +26,8 @@ import static org.mockito.MockitoAnnotations.initMocks;
import com.google.common.base.Optional;
import com.google.common.collect.Lists;
-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.nat.dto.Nat44StaticMappingDetails;
import java.util.Collections;
import java.util.List;
@@ -35,8 +35,8 @@ import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.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.IpAddress;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+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;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.nat.rev180223.nat.instances.instance.mapping.table.MappingEntry;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.nat.rev180223.nat.instances.instance.mapping.table.MappingEntryBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.nat.rev180223.nat.instances.instance.mapping.table.MappingEntryKey;
@@ -59,7 +59,7 @@ public class MappingEntryContextTest implements Ipv4Translator {
when(mappingCtx.read(any(InstanceIdentifier.class))).thenReturn(Optional.absent());
final long natId = 7;
final long entryId = 99;
- final MappingEntry entry = getEntry(natId, "192.168.1.5", "17.14.4.6");
+ final MappingEntry entry = getEntry(natId, "192.168.1.5/32", "17.14.4.6/32");
ctx.addEntry(natId, entryId, entry, mappingCtx);
@@ -69,7 +69,7 @@ public class MappingEntryContextTest implements Ipv4Translator {
@Test
public void testRemove() throws Exception {
final long natId = 0;
- final MappingEntry entry = getEntry(natId, "192.168.1.5", "17.14.4.6");
+ final MappingEntry entry = getEntry(natId, "192.168.1.5/32", "17.14.4.6/32");
ctx.removeEntry(natId, entry, mappingCtx);
@@ -80,7 +80,7 @@ public class MappingEntryContextTest implements Ipv4Translator {
public void testGetExistingIndex() throws Exception {
final long natId = 0;
final long entryId = 12;
- final MappingEntry entry = getEntry(entryId, "192.168.1.5", "17.14.4.6");
+ final MappingEntry entry = getEntry(entryId, "192.168.1.5/32", "17.14.4.6/32");
final Nat44StaticMappingDetails details = getDetails(entryId, "192.168.1.5", "17.14.4.6");
when(mappingCtx.read(MappingEntryContext.getId(natId, MappingEntryContext.entryToKey(entry))))
@@ -93,9 +93,9 @@ public class MappingEntryContextTest implements Ipv4Translator {
@Test
public void testFindDetails() throws Exception {
final long natId = 0;
- final MappingEntry entry = getEntry(0, "192.168.1.5", "17.14.4.6");
+ final MappingEntry entry = getEntry(0, "192.168.1.5/32", "17.14.4.6/32");
final Nat44StaticMappingDetails details = getDetails(0, "192.168.1.5", "17.14.4.6");
- final MappingEntry entry2 = getEntry(1, "192.168.1.8", "17.14.4.10");
+ final MappingEntry entry2 = getEntry(1, "192.168.1.8/32", "17.14.4.10/32");
final Nat44StaticMappingDetails details2 = getDetails(1, "192.168.1.8", "17.14.4.10");
final List<Nat44StaticMappingDetails> someDetails = Lists.newArrayList(details, details2);
@@ -138,16 +138,16 @@ public class MappingEntryContextTest implements Ipv4Translator {
public void testGetArtificialIndex() throws Exception {
final long natId = 0;
final long entryId = 0;
- final MappingEntry entry = getEntry(entryId, "192.168.1.5", "17.14.4.6");
+ final MappingEntry entry = getEntry(entryId, "192.168.1.5/32", "17.14.4.6/32");
final long entryId2 = 55;
- final MappingEntry entry2 = getEntry(entryId2, "192.168.1.6", "17.14.4.7");
+ final MappingEntry entry2 = getEntry(entryId2, "192.168.1.6/32", "17.14.4.7/32");
final long entryId3 = 18954;
- final MappingEntry entry3 = getEntry(entryId3, "192.168.1.7", "17.14.4.8");
+ final MappingEntry entry3 = getEntry(entryId3, "192.168.1.7/32", "17.14.4.8/32");
final long entryId4 = 18955;
- final MappingEntry entry4 = getEntry(entryId4, "192.168.1.8", "17.14.4.9");
+ final MappingEntry entry4 = getEntry(entryId4, "192.168.1.8/32", "17.14.4.9/32");
final long newEntryId = 18956;
- final MappingEntry newEntry = getEntry(newEntryId, "192.168.1.99", "17.14.4.99");
+ final MappingEntry newEntry = getEntry(newEntryId, "192.168.1.99/32", "17.14.4.99/32");
final Nat44StaticMappingDetails newDetails = getDetails(newEntryId, "192.168.1.99", "17.14.4.99");
when(mappingCtx.read(MappingEntryContext.getId(natId, MappingEntryContext.entryToKey(newEntry))))
.thenReturn(Optional.absent());
@@ -178,7 +178,7 @@ public class MappingEntryContextTest implements Ipv4Translator {
public void testAddExisting() throws Exception {
final long natId = 7;
final long entryId = 99;
- final MappingEntry entry = getEntry(natId, "192.168.1.5", "17.14.4.6");
+ final MappingEntry entry = getEntry(natId, "192.168.1.5/32", "17.14.4.6/32");
final org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.nat.context.rev161214.mapping.entry.context.attributes.nat.mapping.entry.context.nat.instance.mapping.table.MappingEntry
data = MappingEntryContext.toCtxMapEntry(entry, entryId);
when(mappingCtx.read(any(InstanceIdentifier.class))).thenReturn(Optional.of(data));
@@ -190,8 +190,8 @@ public class MappingEntryContextTest implements Ipv4Translator {
return new MappingEntryBuilder()
.setKey(new MappingEntryKey(id))
.setType(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.nat.rev180223.MappingEntry.Type.Static)
- .setInternalSrcAddress(new IpAddress(new Ipv4Address(longernalIpv4)))
- .setExternalSrcAddress(new Ipv4Address(externalIpv4))
+ .setInternalSrcAddress(new IpPrefix(new Ipv4Prefix(longernalIpv4)))
+ .setExternalSrcAddress(new IpPrefix(new Ipv4Prefix(externalIpv4)))
.build();
}
} \ No newline at end of file
diff --git a/nat/nat2vpp/src/test/resources/nat44/static-mapping-address-update.json b/nat/nat2vpp/src/test/resources/nat44/static-mapping-address-update.json
index 224a62a6b..6fe329db0 100644
--- a/nat/nat2vpp/src/test/resources/nat44/static-mapping-address-update.json
+++ b/nat/nat2vpp/src/test/resources/nat44/static-mapping-address-update.json
@@ -4,8 +4,8 @@
"index": 22,
"type": "static",
"transport-protocol": 17,
- "internal-src-address": "192.168.1.86",
- "external-src-address": "45.1.5.6"
+ "internal-src-address": "192.168.1.86/32",
+ "external-src-address": "45.1.5.6/32"
}
}
}
diff --git a/nat/nat2vpp/src/test/resources/nat44/static-mapping-unsupported-proto.json b/nat/nat2vpp/src/test/resources/nat44/static-mapping-unsupported-proto.json
index 455465d20..a701e263d 100644
--- a/nat/nat2vpp/src/test/resources/nat44/static-mapping-unsupported-proto.json
+++ b/nat/nat2vpp/src/test/resources/nat44/static-mapping-unsupported-proto.json
@@ -4,8 +4,8 @@
"index": 22,
"type": "static",
"transport-protocol": 123,
- "internal-src-address": "192.168.1.87",
- "external-src-address": "45.1.5.7"
+ "internal-src-address": "192.168.1.87/32",
+ "external-src-address": "45.1.5.7/32"
}
}
}
diff --git a/nat/nat2vpp/src/test/resources/nat44/static-mapping.json b/nat/nat2vpp/src/test/resources/nat44/static-mapping.json
index b1561a46b..a5b5caa4d 100644
--- a/nat/nat2vpp/src/test/resources/nat44/static-mapping.json
+++ b/nat/nat2vpp/src/test/resources/nat44/static-mapping.json
@@ -4,8 +4,8 @@
"index": 22,
"type": "static",
"transport-protocol": 17,
- "internal-src-address": "192.168.1.87",
- "external-src-address": "45.1.5.7"
+ "internal-src-address": "192.168.1.87/32",
+ "external-src-address": "45.1.5.7/32"
}
}
}
diff --git a/nat/nat2vpp/src/test/resources/nat64/static-mapping-address-update.json b/nat/nat2vpp/src/test/resources/nat64/static-mapping-address-update.json
index 2e836ce91..32bfface1 100644
--- a/nat/nat2vpp/src/test/resources/nat64/static-mapping-address-update.json
+++ b/nat/nat2vpp/src/test/resources/nat64/static-mapping-address-update.json
@@ -4,8 +4,8 @@
"index": 58,
"type": "static",
"transport-protocol": 58,
- "internal-src-address": "2001:db8:85a3::8a2e:370:7334",
- "external-src-address": "10.1.1.4",
+ "internal-src-address": "2001:db8:85a3::8a2e:370:7334/128",
+ "external-src-address": "10.1.1.4/32",
"internal-src-port" : {
"start-port-number" : 1234
},
diff --git a/nat/nat2vpp/src/test/resources/nat64/static-mapping-unsupported-proto.json b/nat/nat2vpp/src/test/resources/nat64/static-mapping-unsupported-proto.json
index bbe8a20d3..44432c55b 100644
--- a/nat/nat2vpp/src/test/resources/nat64/static-mapping-unsupported-proto.json
+++ b/nat/nat2vpp/src/test/resources/nat64/static-mapping-unsupported-proto.json
@@ -4,8 +4,8 @@
"index": 58,
"type": "static",
"transport-protocol": 123,
- "internal-src-address": "2001:db8:85a3::8a2e:370:7333",
- "external-src-address": "10.1.1.3"
+ "internal-src-address": "2001:db8:85a3::8a2e:370:7333/128",
+ "external-src-address": "10.1.1.3/32"
}
}
}
diff --git a/nat/nat2vpp/src/test/resources/nat64/static-mapping.json b/nat/nat2vpp/src/test/resources/nat64/static-mapping.json
index 9fff452a2..4312a8841 100644
--- a/nat/nat2vpp/src/test/resources/nat64/static-mapping.json
+++ b/nat/nat2vpp/src/test/resources/nat64/static-mapping.json
@@ -4,11 +4,11 @@
"index": 58,
"type": "static",
"transport-protocol": 58,
- "internal-src-address": "2001:db8:85a3::8a2e:370:7333",
+ "internal-src-address": "2001:db8:85a3::8a2e:370:7333/128",
"internal-src-port": {
"start-port-number": 123
},
- "external-src-address": "10.1.1.3",
+ "external-src-address": "10.1.1.3/32",
"external-src-port": {
"start-port-number": 456
}
diff --git a/nat/nat_postman_collection.json b/nat/nat_postman_collection.json
index 2e6ceeaa0..8013f1cfa 100644
--- a/nat/nat_postman_collection.json
+++ b/nat/nat_postman_collection.json
@@ -434,7 +434,7 @@
"description": "CLI: nat44 add static mapping local 10.0.0.3 external 4.4.4.4\n\nMore information: https://wiki.fd.io/view/VPP/NAT",
"collectionId": "87e0bcaa-5031-9a2b-8a6b-329758310154",
"responses": [],
- "rawModeData": "{\r\n\t\"mapping-entry\" : {\r\n\t\t\"index\": 1,\r\n\t\t\"type\": \"static\",\r\n\t\t\"internal-src-address\": \"192.168.1.87\",\r\n\t\t\"external-src-address\": \"45.1.5.7\"\r\n\t}\r\n}",
+ "rawModeData": "{\r\n\t\"mapping-entry\" : {\r\n\t\t\"index\": 1,\r\n\t\t\"type\": \"static\",\r\n\t\t\"internal-src-address\": \"192.168.1.87/32\",\r\n\t\t\"external-src-address\": \"45.1.5.7/32\"\r\n\t}\r\n}",
"folder": "d256d898-3c36-7ce5-cf2a-74370463d78f"
},
{
@@ -499,8 +499,7 @@
"tests": "",
"currentHelper": "normal",
"helperAttributes": {},
- "folder": "d256d898-3c36-7ce5-cf2a-74370463d78f",
- "rawModeData": "{\r\n\t\"mapping-entry\" : {\r\n\t\t\"index\": 1,\r\n\t\t\"type\": \"static\",\r\n\t\t\"internal-src-address\": \"192.168.1.87\",\r\n\t\t\"external-src-address\": \"45.1.5.7\"\r\n\t}\r\n}"
+ "folder": "d256d898-3c36-7ce5-cf2a-74370463d78f"
},
{
"id": "afdc45a9-cf39-379b-5bb2-4a909512aee3",
@@ -660,7 +659,7 @@
"description": "CLI: nat64 add static bib 2001:db8:85a3::8a2e:370:7334 1234 10.1.1.3 5678 tcp\n\nMore information: https://wiki.fd.io/view/VPP/NAT#Stateful_NAT64",
"collectionId": "87e0bcaa-5031-9a2b-8a6b-329758310154",
"responses": [],
- "rawModeData": "{\n \"mapping-entry\": {\n \"index\": 1,\n \"type\": \"static\",\n \"transport-protocol\": 6,\n \"internal-src-address\": \"2001:db8:85a3::8a2e:370:7334\",\n \"external-src-address\": \"10.1.1.3\",\n \"internal-src-port\": {\n \"start-port-number\": 1234\n },\n \"external-src-port\": {\n \"start-port-number\": 5678\n }\n }\n}"
+ "rawModeData": "{\n \"mapping-entry\": {\n \"index\": 1,\n \"type\": \"static\",\n \"transport-protocol\": 6,\n \"internal-src-address\": \"2001:db8:85a3::8a2e:370:7334/128\",\n \"external-src-address\": \"10.1.1.3/32\",\n \"internal-src-port\": {\n \"start-port-number\": 1234\n },\n \"external-src-port\": {\n \"start-port-number\": 5678\n }\n }\n}"
},
{
"id": "c47386c4-520b-78a5-9c52-a0f36e8aa6d0",