summaryrefslogtreecommitdiffstats
path: root/mpls/impl/src
diff options
context:
space:
mode:
Diffstat (limited to 'mpls/impl/src')
-rw-r--r--mpls/impl/src/main/java/io/fd/hc2vpp/mpls/ImposeAndForwardWriter.java9
-rw-r--r--mpls/impl/src/main/java/io/fd/hc2vpp/mpls/Ipv4LookupWriter.java3
-rw-r--r--mpls/impl/src/main/java/io/fd/hc2vpp/mpls/MplsLookupWriter.java3
-rw-r--r--mpls/impl/src/main/java/io/fd/hc2vpp/mpls/MplsSwapWriter.java6
-rw-r--r--mpls/impl/src/test/java/io/fd/hc2vpp/mpls/ImposeAndForwardTest.java8
-rw-r--r--mpls/impl/src/test/java/io/fd/hc2vpp/mpls/PopAndIpv4LookupTest.java3
-rw-r--r--mpls/impl/src/test/java/io/fd/hc2vpp/mpls/PopAndMplsLookupTest.java3
-rw-r--r--mpls/impl/src/test/java/io/fd/hc2vpp/mpls/SwapAndForwardTest.java6
8 files changed, 27 insertions, 14 deletions
diff --git a/mpls/impl/src/main/java/io/fd/hc2vpp/mpls/ImposeAndForwardWriter.java b/mpls/impl/src/main/java/io/fd/hc2vpp/mpls/ImposeAndForwardWriter.java
index 861ab9ddf..40efd75d6 100644
--- a/mpls/impl/src/main/java/io/fd/hc2vpp/mpls/ImposeAndForwardWriter.java
+++ b/mpls/impl/src/main/java/io/fd/hc2vpp/mpls/ImposeAndForwardWriter.java
@@ -19,11 +19,13 @@ package io.fd.hc2vpp.mpls;
import static com.google.common.base.Preconditions.checkArgument;
import io.fd.hc2vpp.common.translate.util.Ipv4Translator;
+import io.fd.hc2vpp.common.translate.util.MplsLabelTranslator;
import io.fd.hc2vpp.common.translate.util.NamingContext;
import io.fd.honeycomb.translate.MappingContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.vpp.jvpp.core.dto.IpAddDelRoute;
import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import io.fd.vpp.jvpp.core.types.FibMplsLabel;
import java.util.List;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
@@ -47,7 +49,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
*
* @see <a href="https://git.fd.io/vpp/tree/src/vnet/ip/ip.api">ip_add_del_route</a> definition
*/
-final class ImposeAndForwardWriter implements LspWriter, Ipv4Translator {
+final class ImposeAndForwardWriter implements LspWriter, Ipv4Translator, MplsLabelTranslator {
private final FutureJVppCore vppApi;
private final NamingContext interfaceContext;
@@ -115,7 +117,7 @@ final class ImposeAndForwardWriter implements LspWriter, Ipv4Translator {
final MplsLabel outgoingLabel = path.getOutgoingLabel();
checkArgument(outgoingLabel != null, "Configuring impose-and-forward, but outgoing-label is missing.");
- request.nextHopOutLabelStack = new int[] {outgoingLabel.getValue().intValue()};
+ request.nextHopOutLabelStack = new FibMplsLabel[] {translate(outgoingLabel.getValue())};
request.nextHopNOutLabels = 1;
return path.getOutgoingInterface();
@@ -140,7 +142,8 @@ final class ImposeAndForwardWriter implements LspWriter, Ipv4Translator {
checkArgument(numberOfLabels > 0 && numberOfLabels < MAX_LABELS, "Number of labels (%s) not in range (0, %s].",
numberOfLabels, MAX_LABELS, numberOfLabels);
request.nextHopNOutLabels = (byte) numberOfLabels;
- request.nextHopOutLabelStack = labels.stream().mapToInt(label -> label.getValue().intValue()).toArray();
+ request.nextHopOutLabelStack =
+ labels.stream().map(label -> translate(label.getValue())).toArray(FibMplsLabel[]::new);
return paths.getOutgoingInterface();
}
diff --git a/mpls/impl/src/main/java/io/fd/hc2vpp/mpls/Ipv4LookupWriter.java b/mpls/impl/src/main/java/io/fd/hc2vpp/mpls/Ipv4LookupWriter.java
index 94862c52b..be26166d3 100644
--- a/mpls/impl/src/main/java/io/fd/hc2vpp/mpls/Ipv4LookupWriter.java
+++ b/mpls/impl/src/main/java/io/fd/hc2vpp/mpls/Ipv4LookupWriter.java
@@ -22,6 +22,7 @@ import io.fd.honeycomb.translate.MappingContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.vpp.jvpp.core.dto.MplsRouteAddDel;
import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import io.fd.vpp.jvpp.core.types.FibMplsLabel;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.mpls._static.rev170310.StaticLspConfig;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.mpls._static.rev170310._static.lsp.Config;
@@ -61,7 +62,7 @@ final class Ipv4LookupWriter implements LspWriter, MplsInSegmentTranslator {
request.mrNextHopProto = IPV4_PROTOCOL;
request.mrNextHopWeight = 1;
request.mrNextHop = new byte[0]; // no next hop since we POP
- request.mrNextHopOutLabelStack = new int[0]; // no new labels
+ request.mrNextHopOutLabelStack = new FibMplsLabel[0]; // no new labels
request.mrNextHopSwIfIndex = -1;
request.mrNextHopViaLabel = MPLS_LABEL_INVALID;
diff --git a/mpls/impl/src/main/java/io/fd/hc2vpp/mpls/MplsLookupWriter.java b/mpls/impl/src/main/java/io/fd/hc2vpp/mpls/MplsLookupWriter.java
index d5d4872dc..86e7bdee1 100644
--- a/mpls/impl/src/main/java/io/fd/hc2vpp/mpls/MplsLookupWriter.java
+++ b/mpls/impl/src/main/java/io/fd/hc2vpp/mpls/MplsLookupWriter.java
@@ -22,6 +22,7 @@ import io.fd.honeycomb.translate.MappingContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.vpp.jvpp.core.dto.MplsRouteAddDel;
import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import io.fd.vpp.jvpp.core.types.FibMplsLabel;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.mpls._static.rev170310.StaticLspConfig;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.mpls._static.rev170310._static.lsp.Config;
@@ -61,7 +62,7 @@ final class MplsLookupWriter implements LspWriter, MplsInSegmentTranslator {
request.mrNextHopProto = MPLS_PROTOCOL;
request.mrNextHopWeight = 1;
request.mrNextHop = new byte[0]; // no next hop since we POP
- request.mrNextHopOutLabelStack = new int[0]; // no new labels
+ request.mrNextHopOutLabelStack = new FibMplsLabel[0]; // no new labels
request.mrNextHopSwIfIndex = -1;
request.mrNextHopViaLabel = MPLS_LABEL_INVALID;
diff --git a/mpls/impl/src/main/java/io/fd/hc2vpp/mpls/MplsSwapWriter.java b/mpls/impl/src/main/java/io/fd/hc2vpp/mpls/MplsSwapWriter.java
index 8d834fe7c..28aba7aa8 100644
--- a/mpls/impl/src/main/java/io/fd/hc2vpp/mpls/MplsSwapWriter.java
+++ b/mpls/impl/src/main/java/io/fd/hc2vpp/mpls/MplsSwapWriter.java
@@ -19,11 +19,13 @@ package io.fd.hc2vpp.mpls;
import static com.google.common.base.Preconditions.checkArgument;
import io.fd.hc2vpp.common.translate.util.Ipv4Translator;
+import io.fd.hc2vpp.common.translate.util.MplsLabelTranslator;
import io.fd.hc2vpp.common.translate.util.NamingContext;
import io.fd.honeycomb.translate.MappingContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.vpp.jvpp.core.dto.MplsRouteAddDel;
import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import io.fd.vpp.jvpp.core.types.FibMplsLabel;
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;
@@ -40,7 +42,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
*
* @see <a href="https://git.fd.io/vpp/tree/src/vnet/mpls/mpls.api">mpls_route_add_del</a> definition
*/
-final class MplsSwapWriter implements LspWriter, Ipv4Translator, MplsInSegmentTranslator {
+final class MplsSwapWriter implements LspWriter, Ipv4Translator, MplsInSegmentTranslator, MplsLabelTranslator {
private final FutureJVppCore vppApi;
private final NamingContext interfaceContext;
@@ -83,7 +85,7 @@ final class MplsSwapWriter implements LspWriter, Ipv4Translator, MplsInSegmentTr
final MplsLabel outgoingLabel = path.getOutgoingLabel();
checkArgument(outgoingLabel != null, "Configuring swap-and-forward, but outgoing-label is missing.");
- request.mrNextHopOutLabelStack = new int[] {outgoingLabel.getValue().intValue()};
+ request.mrNextHopOutLabelStack = new FibMplsLabel[] {translate(outgoingLabel.getValue())};
request.mrNextHopNOutLabels = 1;
final String outgoingInterface = path.getOutgoingInterface();
diff --git a/mpls/impl/src/test/java/io/fd/hc2vpp/mpls/ImposeAndForwardTest.java b/mpls/impl/src/test/java/io/fd/hc2vpp/mpls/ImposeAndForwardTest.java
index c1ced8e1d..6eb559da8 100644
--- a/mpls/impl/src/test/java/io/fd/hc2vpp/mpls/ImposeAndForwardTest.java
+++ b/mpls/impl/src/test/java/io/fd/hc2vpp/mpls/ImposeAndForwardTest.java
@@ -23,11 +23,13 @@ import static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet
import io.fd.hc2vpp.common.test.write.WriterCustomizerTest;
import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
+import io.fd.hc2vpp.common.translate.util.MplsLabelTranslator;
import io.fd.hc2vpp.common.translate.util.NamingContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.vpp.jvpp.core.dto.IpAddDelRoute;
import io.fd.vpp.jvpp.core.dto.IpAddDelRouteReply;
import io.fd.vpp.jvpp.core.future.FutureJVppCoreFacade;
+import io.fd.vpp.jvpp.core.types.FibMplsLabel;
import java.util.Arrays;
import java.util.Collections;
import org.junit.Test;
@@ -52,7 +54,7 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.types.rev170227.MplsLabel;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-public class ImposeAndForwardTest extends WriterCustomizerTest implements ByteDataTranslator {
+public class ImposeAndForwardTest extends WriterCustomizerTest implements ByteDataTranslator, MplsLabelTranslator {
private static final String IF_NAME = "local0";
private static final int IF_INDEX = 123;
@@ -180,7 +182,7 @@ public class ImposeAndForwardTest extends WriterCustomizerTest implements ByteDa
request.nextHopAddress = nextHop;
request.nextHopNOutLabels = 1;
request.nextHopViaLabel = LspWriter.MPLS_LABEL_INVALID;
- request.nextHopOutLabelStack = new int[] {label};
+ request.nextHopOutLabelStack = new FibMplsLabel[] {translate(label)};
return request;
}
@@ -194,7 +196,7 @@ public class ImposeAndForwardTest extends WriterCustomizerTest implements ByteDa
request.nextHopAddress = new byte[] {10, 10, 12, 2};
request.nextHopNOutLabels = 2;
request.nextHopViaLabel = LspWriter.MPLS_LABEL_INVALID;
- request.nextHopOutLabelStack = new int[] {102, 104};
+ request.nextHopOutLabelStack = new FibMplsLabel[] {translate(102), translate(104)};
return request;
}
}
diff --git a/mpls/impl/src/test/java/io/fd/hc2vpp/mpls/PopAndIpv4LookupTest.java b/mpls/impl/src/test/java/io/fd/hc2vpp/mpls/PopAndIpv4LookupTest.java
index e924cfaaf..61e1c6d58 100644
--- a/mpls/impl/src/test/java/io/fd/hc2vpp/mpls/PopAndIpv4LookupTest.java
+++ b/mpls/impl/src/test/java/io/fd/hc2vpp/mpls/PopAndIpv4LookupTest.java
@@ -27,6 +27,7 @@ import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.vpp.jvpp.core.dto.MplsRouteAddDel;
import io.fd.vpp.jvpp.core.dto.MplsRouteAddDelReply;
import io.fd.vpp.jvpp.core.future.FutureJVppCoreFacade;
+import io.fd.vpp.jvpp.core.types.FibMplsLabel;
import org.junit.Test;
import org.mockito.Mock;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.mpls._static.rev170310.Mpls1;
@@ -119,7 +120,7 @@ public class PopAndIpv4LookupTest extends WriterCustomizerTest implements ByteDa
request.mrNextHop = new byte[0]; // POP, so no next hop
request.mrNextHopSwIfIndex = -1; // this is what CLI is doing
request.mrNextHopViaLabel = LspWriter.MPLS_LABEL_INVALID; // default value used by make test
- request.mrNextHopOutLabelStack = new int[0];
+ request.mrNextHopOutLabelStack = new FibMplsLabel[0];
return request;
}
}
diff --git a/mpls/impl/src/test/java/io/fd/hc2vpp/mpls/PopAndMplsLookupTest.java b/mpls/impl/src/test/java/io/fd/hc2vpp/mpls/PopAndMplsLookupTest.java
index de32a1907..f5a76974a 100644
--- a/mpls/impl/src/test/java/io/fd/hc2vpp/mpls/PopAndMplsLookupTest.java
+++ b/mpls/impl/src/test/java/io/fd/hc2vpp/mpls/PopAndMplsLookupTest.java
@@ -27,6 +27,7 @@ import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.vpp.jvpp.core.dto.MplsRouteAddDel;
import io.fd.vpp.jvpp.core.dto.MplsRouteAddDelReply;
import io.fd.vpp.jvpp.core.future.FutureJVppCoreFacade;
+import io.fd.vpp.jvpp.core.types.FibMplsLabel;
import org.junit.Test;
import org.mockito.Mock;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.mpls._static.rev170310.Mpls1;
@@ -119,7 +120,7 @@ public class PopAndMplsLookupTest extends WriterCustomizerTest implements ByteDa
request.mrNextHop = new byte[0]; // POP, so no next hop
request.mrNextHopSwIfIndex = -1; // this is what CLI is doing
request.mrNextHopViaLabel = LspWriter.MPLS_LABEL_INVALID; // default value used by make test
- request.mrNextHopOutLabelStack = new int[0];
+ request.mrNextHopOutLabelStack = new FibMplsLabel[0];
return request;
}
}
diff --git a/mpls/impl/src/test/java/io/fd/hc2vpp/mpls/SwapAndForwardTest.java b/mpls/impl/src/test/java/io/fd/hc2vpp/mpls/SwapAndForwardTest.java
index 6fd9e02f5..5b0e124f0 100644
--- a/mpls/impl/src/test/java/io/fd/hc2vpp/mpls/SwapAndForwardTest.java
+++ b/mpls/impl/src/test/java/io/fd/hc2vpp/mpls/SwapAndForwardTest.java
@@ -22,11 +22,13 @@ import static org.mockito.Mockito.when;
import io.fd.hc2vpp.common.test.write.WriterCustomizerTest;
import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
+import io.fd.hc2vpp.common.translate.util.MplsLabelTranslator;
import io.fd.hc2vpp.common.translate.util.NamingContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.vpp.jvpp.core.dto.MplsRouteAddDel;
import io.fd.vpp.jvpp.core.dto.MplsRouteAddDelReply;
import io.fd.vpp.jvpp.core.future.FutureJVppCoreFacade;
+import io.fd.vpp.jvpp.core.types.FibMplsLabel;
import org.junit.Test;
import org.mockito.Mock;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressBuilder;
@@ -46,7 +48,7 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.types.rev170227.MplsLabel;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-public class SwapAndForwardTest extends WriterCustomizerTest implements ByteDataTranslator {
+public class SwapAndForwardTest extends WriterCustomizerTest implements ByteDataTranslator, MplsLabelTranslator {
private static final String IF_NAME = "local0";
private static final int IF_INDEX = 123;
@@ -117,7 +119,7 @@ public class SwapAndForwardTest extends WriterCustomizerTest implements ByteData
request.mrNextHopSwIfIndex = IF_INDEX;
request.mrNextHopViaLabel = LspWriter.MPLS_LABEL_INVALID; // default value used by make test
request.mrNextHopNOutLabels = 1;
- request.mrNextHopOutLabelStack = new int[] {OUT_LABEL};
+ request.mrNextHopOutLabelStack = new FibMplsLabel[] {translate(OUT_LABEL)};
return request;
}
}