summaryrefslogtreecommitdiffstats
path: root/nat/nat2vpp/src/main/java/io/fd
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2017-02-21 13:02:12 +0100
committerJan Srnicek <jsrnicek@cisco.com>2017-02-23 06:25:49 +0000
commitec441a2601397ae0738152615860a8f011dd16c4 (patch)
tree664f54cac83bdc9621d57e9e25e3b630a04e2953 /nat/nat2vpp/src/main/java/io/fd
parent4c4bb0911d3556c834fd384aa1ef7c4d4ce69a33 (diff)
HC2VPP-80: add support for protcol configuration
Change-Id: I7ad92c7ba78da3fd1b42605f4f0987df83d41d9f Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'nat/nat2vpp/src/main/java/io/fd')
-rw-r--r--nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/write/MappingEntryCustomizer.java11
1 files changed, 9 insertions, 2 deletions
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 b2852fa4f..ecffe9ca9 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
@@ -19,10 +19,10 @@ package io.fd.hc2vpp.nat.write;
import static com.google.common.base.Preconditions.checkArgument;
import com.google.common.base.Optional;
-import io.fd.hc2vpp.nat.util.MappingEntryContext;
-import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
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.spi.write.ListWriterCustomizer;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.vpp.jvpp.snat.dto.SnatAddStaticMapping;
@@ -151,6 +151,13 @@ final class MappingEntryCustomizer implements ListWriterCustomizer<MappingEntry,
ipv4AddressNoZoneToArray(dataAfter.getInternalSrcAddress().getIpv4Address().getValue());
request.externalIpAddress = ipv4AddressNoZoneToArray(dataAfter.getExternalSrcAddress().getValue());
request.externalSwIfIndex = -1; // external ip address is ignored if externalSwIfIndex is given
+ request.protocol = -1;
+ final Short protocol = dataAfter.getTransportProtocol();
+ if (protocol != null) {
+ checkArgument(protocol == 1 || protocol == 6 || protocol == 17,
+ "Unsupported protocol %s only ICMP, TCP and UDP are currently supported", protocol);
+ request.protocol = protocol.byteValue();
+ }
Optional<Short> internalPortNumber = getPortNumber(id, dataAfter,
(entry) -> Optional.fromNullable(entry.getInternalSrcPort()).transform(PortNumber::getPortType));