summaryrefslogtreecommitdiffstats
path: root/srv6/srv6-impl/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'srv6/srv6-impl/src/main/java')
-rw-r--r--srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/Srv6Configuration.java35
-rw-r--r--srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/Srv6IIds.java96
-rw-r--r--srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/Srv6Module.java48
-rw-r--r--srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/JVppRequest.java38
-rw-r--r--srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/LocalSidFunctionBinder.java70
-rw-r--r--srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/LocalSidFunctionBindingRegistry.java50
-rw-r--r--srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/LocalSidFunctionWriteBindingRegistry.java34
-rw-r--r--srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/LocalSidFunctionWriteBindingRegistryProvider.java56
-rw-r--r--srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/lookup/EndDT4FunctionBinder.java49
-rw-r--r--srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/lookup/EndDT6FunctionBinder.java49
-rw-r--r--srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/lookup/EndTFunctionBinder.java47
-rw-r--r--srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/lookup/TableLookupFunctionBinder.java76
-rw-r--r--srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/nofunction/EndFunctionBinder.java58
-rw-r--r--srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/xconnect/EndDX2FunctionBinder.java56
-rw-r--r--srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/xconnect/EndDX4FunctionBinder.java60
-rw-r--r--srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/xconnect/EndDX6FunctionBinder.java60
-rw-r--r--srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/xconnect/EndXFunctionBinder.java61
-rw-r--r--srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/xconnect/XConnectFunctionBinder.java65
-rw-r--r--srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/DeleteRequest.java25
-rw-r--r--srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/Srv6Customizer.java49
-rw-r--r--srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/Srv6WriterFactory.java59
-rw-r--r--srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/UpdateRequest.java25
-rw-r--r--srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/WriteRequest.java25
-rw-r--r--srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/encap/source/EncapsulationSourceCustomizer.java60
-rw-r--r--srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/encap/source/request/EncapsulationSourceDeleteRequest.java39
-rw-r--r--srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/encap/source/request/EncapsulationSourceWriteRequest.java58
-rw-r--r--srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/sid/LocatorCustomizer.java45
-rw-r--r--srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/sid/SidCustomizer.java136
-rw-r--r--srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/sid/request/LocalSidFunctionRequest.java133
-rw-r--r--srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/sid/request/NoProtocolLocalSidRequest.java29
-rw-r--r--srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/sid/request/TableLookupLocalSidRequest.java49
-rw-r--r--srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/sid/request/XConnectLocalSidRequest.java87
32 files changed, 1827 insertions, 0 deletions
diff --git a/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/Srv6Configuration.java b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/Srv6Configuration.java
new file mode 100644
index 000000000..8d23b1703
--- /dev/null
+++ b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/Srv6Configuration.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.srv6;
+
+public class Srv6Configuration {
+
+ /**
+ * Used to map Srv6 Sids to locator length values
+ */
+ public static final String LOCATOR_CONTEXT = "locator-context";
+
+ /**
+ * Locator length context child name for locator length
+ */
+ public static final String LOCATOR_LENGTH = "locator-length";
+
+ /**
+ * Locator length context child name for locator length
+ */
+ public static final String LOCATOR_IPV6_ADDRESS = "locator-ipv6-address";
+}
diff --git a/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/Srv6IIds.java b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/Srv6IIds.java
new file mode 100644
index 000000000..53c0df6d1
--- /dev/null
+++ b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/Srv6IIds.java
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package io.fd.hc2vpp.srv6;
+
+import org.opendaylight.yang.gen.v1.urn.hc2vpp.params.xml.ns.yang.vpp.ietf.srv6.base.rev180613.VppSrv6FibLocatorAugment;
+import org.opendaylight.yang.gen.v1.urn.hc2vpp.params.xml.ns.yang.vpp.ietf.srv6.base.rev180613.vpp.srv6.fib.FibTable;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev180313.Routing;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6._static.rev180301.Locator1;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6._static.rev180301.multi.paths.v6.Paths;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6._static.rev180301.multi.paths.v6.paths.Path;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6._static.rev180301.routing.srv6.locators.locator.Static;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6._static.rev180301.routing.srv6.locators.locator._static.LocalSids;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6._static.rev180301.srv6._static.cfg.Sid;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6._static.rev180301.srv6.sid.config.End;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6._static.rev180301.srv6.sid.config.EndB6;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6._static.rev180301.srv6.sid.config.EndB6Encaps;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6._static.rev180301.srv6.sid.config.EndBm;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6._static.rev180301.srv6.sid.config.EndDt4;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6._static.rev180301.srv6.sid.config.EndDt46;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6._static.rev180301.srv6.sid.config.EndDt6;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6._static.rev180301.srv6.sid.config.EndDx2;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6._static.rev180301.srv6.sid.config.EndDx4;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6._static.rev180301.srv6.sid.config.EndDx6;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6._static.rev180301.srv6.sid.config.EndT;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6._static.rev180301.srv6.sid.config.EndX;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6.base.rev180301.Routing1;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6.base.rev180301.routing.Srv6;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6.base.rev180301.srv6.encap.Encapsulation;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6.base.rev180301.srv6.locators.Locators;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6.base.rev180301.srv6.locators.locators.Locator;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6.base.rev180301.srv6.locators.locators.locator.Prefix;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class Srv6IIds {
+ public final static InstanceIdentifier<Routing> RT = InstanceIdentifier.create(Routing.class);
+ public final static InstanceIdentifier<Routing1> RT_RT1_AUG = RT.augmentation(Routing1.class);
+ public final static InstanceIdentifier<Srv6> RT_SRV6 = RT_RT1_AUG.child(Srv6.class);
+ public final static InstanceIdentifier<Locators> RT_SRV6_LOCATORS = RT_SRV6.child(Locators.class);
+ public final static InstanceIdentifier<Locator> RT_SRV6_LOCS_LOCATOR = RT_SRV6_LOCATORS.child(Locator.class);
+ public final static InstanceIdentifier<Locator> LOCATOR = InstanceIdentifier.create(Locator.class);
+ public final static InstanceIdentifier<VppSrv6FibLocatorAugment> LOC_FT_AUG =
+ LOCATOR.augmentation(VppSrv6FibLocatorAugment.class);
+ public final static InstanceIdentifier<FibTable> LOC_FT = LOC_FT_AUG.child(FibTable.class);
+
+ public final static InstanceIdentifier<Prefix> LOC_PREFIX = LOCATOR.child(Prefix.class);
+ public final static InstanceIdentifier<Locator1> RT_SRV6_LOCS_LOC_AUG =
+ RT_SRV6_LOCS_LOCATOR.augmentation(Locator1.class);
+ public final static InstanceIdentifier<Static> RT_SRV6_LOCS_LOC_STATIC = RT_SRV6_LOCS_LOC_AUG.child(Static.class);
+ public final static InstanceIdentifier<LocalSids> RT_SRV6_LOCS_LOC_ST_LOCALSIDS =
+ RT_SRV6_LOCS_LOC_STATIC.child(LocalSids.class);
+ public final static InstanceIdentifier<Sid> RT_SRV6_LOCS_LOC_ST_LS_SID =
+ RT_SRV6_LOCS_LOC_ST_LOCALSIDS.child(Sid.class);
+ public final static InstanceIdentifier<Encapsulation> RT_SRV6_ENCAP = RT_SRV6.child(Encapsulation.class);
+
+ public final static InstanceIdentifier<Sid> SID = InstanceIdentifier.create(Sid.class);
+ public final static InstanceIdentifier<End> SID_END = SID.child(End.class);
+ public final static InstanceIdentifier<EndX> SID_END_X = SID.child(EndX.class);
+ public final static InstanceIdentifier<Paths> SID_END_X_PATHS = SID_END_X.child(Paths.class);
+ public final static InstanceIdentifier<Path> SID_END_X_PATHS_PATH = SID_END_X_PATHS.child(Path.class);
+ public final static InstanceIdentifier<EndT> SID_END_T = SID.child(EndT.class);
+ public final static InstanceIdentifier<EndB6> SID_END_B6 = SID.child(EndB6.class);
+ public final static InstanceIdentifier<EndB6Encaps> SID_END_B6ENCAP = SID.child(EndB6Encaps.class);
+ public final static InstanceIdentifier<EndBm> SID_END_BM = SID.child(EndBm.class);
+ public final static InstanceIdentifier<EndDt4> SID_END_DT4 = SID.child(EndDt4.class);
+ public final static InstanceIdentifier<EndDt6> SID_END_DT6 = SID.child(EndDt6.class);
+ public final static InstanceIdentifier<EndDt46> SID_END_DT46 = SID.child(EndDt46.class);
+ public final static InstanceIdentifier<EndDx2> SID_END_DX2 = SID.child(EndDx2.class);
+ public final static InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6._static.rev180301.srv6.sid.config.end.dx2.Paths>
+ SID_END_DX2_PATHS = SID_END_DX2.child(
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6._static.rev180301.srv6.sid.config.end.dx2.Paths.class);
+ public final static InstanceIdentifier<EndDx4> SID_END_DX4 = SID.child(EndDx4.class);
+ public final static InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6._static.rev180301.multi.paths.v4.Paths>
+ SID_END_DX4_PATHS = SID_END_DX4.child(
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6._static.rev180301.multi.paths.v4.Paths.class);
+ public final static InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6._static.rev180301.multi.paths.v4.paths.Path>
+ SID_END_DX4_PATHS_PATH = SID_END_DX4_PATHS.child(
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6._static.rev180301.multi.paths.v4.paths.Path.class);
+ public final static InstanceIdentifier<EndDx6> SID_END_DX6 = SID.child(EndDx6.class);
+ public final static InstanceIdentifier<Paths> SID_END_DX6_PATHS = SID_END_DX6.child(Paths.class);
+ public final static InstanceIdentifier<Path> SID_END_DX6_PATHS_PATH = SID_END_DX6_PATHS.child(Path.class);
+}
diff --git a/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/Srv6Module.java b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/Srv6Module.java
new file mode 100644
index 000000000..5dd3e2097
--- /dev/null
+++ b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/Srv6Module.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.srv6;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Singleton;
+import com.google.inject.multibindings.Multibinder;
+import io.fd.hc2vpp.srv6.util.function.LocalSidFunctionWriteBindingRegistry;
+import io.fd.hc2vpp.srv6.util.function.LocalSidFunctionWriteBindingRegistryProvider;
+import io.fd.hc2vpp.srv6.write.Srv6WriterFactory;
+import io.fd.honeycomb.translate.write.WriterFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class Srv6Module extends AbstractModule {
+
+ private static final Logger LOG = LoggerFactory.getLogger(Srv6Module.class);
+
+ @Override
+ protected void configure() {
+ LOG.info("Installing SRv6 module");
+ LOG.info("Reading SRv6 configuration");
+ requestInjection(Srv6Configuration.class);
+
+ bind(LocalSidFunctionWriteBindingRegistry.class).toProvider(LocalSidFunctionWriteBindingRegistryProvider.class)
+ .in(Singleton.class);
+
+ LOG.info("Injecting SRv6 writers");
+ final Multibinder<WriterFactory> writeBinder = Multibinder.newSetBinder(binder(), WriterFactory.class);
+ writeBinder.addBinding().to(Srv6WriterFactory.class);
+
+ LOG.info("SRv6 module successfully configured");
+ }
+}
diff --git a/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/JVppRequest.java b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/JVppRequest.java
new file mode 100644
index 000000000..9ea9fff30
--- /dev/null
+++ b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/JVppRequest.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.srv6.util;
+
+import io.fd.hc2vpp.common.translate.util.AddressTranslator;
+import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+
+public abstract class JVppRequest implements AddressTranslator, JvppReplyConsumer {
+
+ private final FutureJVppCore api;
+
+ protected JVppRequest(final FutureJVppCore api) {
+ this.api = api;
+ }
+
+ protected FutureJVppCore getApi() {
+ return api;
+ }
+
+ public void checkValid() {
+ //noop
+ }
+}
diff --git a/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/LocalSidFunctionBinder.java b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/LocalSidFunctionBinder.java
new file mode 100644
index 000000000..e51ee5ac5
--- /dev/null
+++ b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/LocalSidFunctionBinder.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.srv6.util.function;
+
+import io.fd.hc2vpp.srv6.write.sid.request.LocalSidFunctionRequest;
+import io.fd.honeycomb.translate.write.WriteContext;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6._static.rev180301.srv6._static.cfg.Sid;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6.types.rev180301.Srv6EndpointType;
+
+/**
+ * Binder interface, which is used to map yang model data classes of local sid functions to local sid function requests
+ * used to configure endpoint functions on VPP. It uses behavior function type integer value defined by VPP API, to find
+ * suitable binder. This value is translated to {@link Srv6EndpointType} in model, which represents the same endpoint
+ * function as defined by VPP API.
+ *
+ * @param <T> Type which extends general interface for {@link LocalSidFunctionRequest} and represents template binder
+ * that is used to process end function data represented by provided class type.
+ */
+public interface LocalSidFunctionBinder<T extends LocalSidFunctionRequest> {
+
+ /**
+ * Binds request accordingly to type of function implemented by this interface
+ *
+ * @return request with all attributes necessary for this function
+ */
+ @Nonnull
+ T createWriteRequestAndBind(@Nonnull final Sid data, @Nonnull final WriteContext ctx);
+
+ /**
+ * Provides Endpoint function type class.
+ * @return Endpoint function class
+ */
+ @Nonnull
+ Class<? extends Srv6EndpointType> getHandledFunctionType();
+
+ /**
+ * Provide behavior function type integer value.
+ *
+ * @return integer value of behaviour function type as defined in VPP api
+ */
+ int getBehaviourFunctionType();
+
+ /**
+ * Checks whether binder can handle provided data
+ *
+ * @param data sid function data to be checked
+ * @return true if function binder is able to process provided data, false otherwise
+ */
+ default boolean canHandle(final Sid data) {
+ if (data == null || data.getEndBehaviorType() == null) {
+ return false;
+ }
+ return data.getEndBehaviorType().equals(getHandledFunctionType());
+ }
+}
diff --git a/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/LocalSidFunctionBindingRegistry.java b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/LocalSidFunctionBindingRegistry.java
new file mode 100644
index 000000000..d56656fb9
--- /dev/null
+++ b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/LocalSidFunctionBindingRegistry.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.srv6.util.function;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import io.fd.hc2vpp.srv6.write.sid.request.LocalSidFunctionRequest;
+import java.util.ArrayList;
+import java.util.List;
+import javax.annotation.Nonnull;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+abstract class LocalSidFunctionBindingRegistry<T extends LocalSidFunctionRequest> {
+
+ private static final Logger LOG = LoggerFactory.getLogger(LocalSidFunctionBindingRegistry.class);
+ final List<LocalSidFunctionBinder<T>> binders;
+
+ LocalSidFunctionBindingRegistry() {
+ binders = new ArrayList<>();
+ }
+
+ @SuppressWarnings("unchecked")
+ public void registerFunctionType(@Nonnull final LocalSidFunctionBinder binder) {
+ checkNotNull(binder, "Cannot register null binder");
+ if (!isFunctionRegistered(binder)) {
+ binders.add(binder);
+ } else {
+ LOG.warn("Binder for class already registered. Canceling registration for {}.", binder);
+ }
+ }
+
+ private boolean isFunctionRegistered(@Nonnull final LocalSidFunctionBinder binder) {
+ return binders.stream().parallel().anyMatch(locBinder -> locBinder.getClass().equals(binder.getClass()));
+ }
+}
diff --git a/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/LocalSidFunctionWriteBindingRegistry.java b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/LocalSidFunctionWriteBindingRegistry.java
new file mode 100644
index 000000000..b74a7668b
--- /dev/null
+++ b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/LocalSidFunctionWriteBindingRegistry.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.srv6.util.function;
+
+import io.fd.hc2vpp.srv6.write.sid.request.LocalSidFunctionRequest;
+import io.fd.honeycomb.translate.util.RWUtils;
+import io.fd.honeycomb.translate.write.WriteContext;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6._static.rev180301.srv6._static.cfg.Sid;
+
+public class LocalSidFunctionWriteBindingRegistry<T extends LocalSidFunctionRequest>
+ extends LocalSidFunctionBindingRegistry<T> {
+
+ public LocalSidFunctionRequest bind(final Sid localSid, @Nonnull final WriteContext ctx) {
+ return binders.parallelStream()
+ .filter(toLocalSidFunctionBinder -> toLocalSidFunctionBinder.canHandle(localSid))
+ .map(binder -> binder.createWriteRequestAndBind(localSid, ctx))
+ .collect(RWUtils.singleItemCollector());
+ }
+}
diff --git a/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/LocalSidFunctionWriteBindingRegistryProvider.java b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/LocalSidFunctionWriteBindingRegistryProvider.java
new file mode 100644
index 000000000..20189b702
--- /dev/null
+++ b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/LocalSidFunctionWriteBindingRegistryProvider.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.srv6.util.function;
+
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.hc2vpp.srv6.util.function.lookup.EndDT4FunctionBinder;
+import io.fd.hc2vpp.srv6.util.function.lookup.EndDT6FunctionBinder;
+import io.fd.hc2vpp.srv6.util.function.lookup.EndTFunctionBinder;
+import io.fd.hc2vpp.srv6.util.function.nofunction.EndFunctionBinder;
+import io.fd.hc2vpp.srv6.util.function.xconnect.EndDX2FunctionBinder;
+import io.fd.hc2vpp.srv6.util.function.xconnect.EndDX4FunctionBinder;
+import io.fd.hc2vpp.srv6.util.function.xconnect.EndDX6FunctionBinder;
+import io.fd.hc2vpp.srv6.util.function.xconnect.EndXFunctionBinder;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import javax.inject.Named;
+
+public class LocalSidFunctionWriteBindingRegistryProvider implements Provider<LocalSidFunctionWriteBindingRegistry> {
+
+ @Inject
+ @Named("interface-context")
+ private NamingContext interfaceContext;
+
+ @Inject
+ private FutureJVppCore api;
+ private final LocalSidFunctionWriteBindingRegistry registry = new LocalSidFunctionWriteBindingRegistry();
+
+ @Override
+ public LocalSidFunctionWriteBindingRegistry get() {
+ registry.registerFunctionType(new EndFunctionBinder(api));
+ registry.registerFunctionType(new EndTFunctionBinder(api));
+ registry.registerFunctionType(new EndDT4FunctionBinder(api));
+ registry.registerFunctionType(new EndDT6FunctionBinder(api));
+ registry.registerFunctionType(new EndXFunctionBinder(api, interfaceContext));
+ registry.registerFunctionType(new EndDX2FunctionBinder(api, interfaceContext));
+ registry.registerFunctionType(new EndDX4FunctionBinder(api, interfaceContext));
+ registry.registerFunctionType(new EndDX6FunctionBinder(api, interfaceContext));
+
+ return registry;
+ }
+}
diff --git a/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/lookup/EndDT4FunctionBinder.java b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/lookup/EndDT4FunctionBinder.java
new file mode 100644
index 000000000..e8ea22419
--- /dev/null
+++ b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/lookup/EndDT4FunctionBinder.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.srv6.util.function.lookup;
+
+import com.google.common.base.Preconditions;
+import io.fd.hc2vpp.srv6.write.sid.request.TableLookupLocalSidRequest;
+import io.fd.honeycomb.translate.write.WriteContext;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6._static.rev180301.srv6._static.cfg.Sid;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6.types.rev180301.EndDT4;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6.types.rev180301.Srv6EndpointType;
+
+public class EndDT4FunctionBinder extends TableLookupFunctionBinder {
+
+ public EndDT4FunctionBinder(@Nonnull final FutureJVppCore api) {
+ super(api);
+ }
+
+ @Nonnull
+ @Override
+ public TableLookupLocalSidRequest createWriteRequestAndBind(@Nonnull Sid data,
+ @Nonnull WriteContext ctx) {
+ Preconditions.checkNotNull(data.getEndDt4(), "EndDt4 data cannot be null.");
+ Preconditions.checkNotNull(data.getEndDt4().getLookupTableIpv4(), "EndDt4 lookup table cannot be null.");
+ int lookupTable = data.getEndDt4().getLookupTableIpv4().getValue().intValue();
+ return bindData(new TableLookupLocalSidRequest(getFutureJVpp()), lookupTable, false, ctx);
+ }
+
+ @Override
+ @Nonnull
+ public Class<? extends Srv6EndpointType> getHandledFunctionType() {
+ return EndDT4.class;
+ }
+}
diff --git a/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/lookup/EndDT6FunctionBinder.java b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/lookup/EndDT6FunctionBinder.java
new file mode 100644
index 000000000..01e6c6bb2
--- /dev/null
+++ b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/lookup/EndDT6FunctionBinder.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.srv6.util.function.lookup;
+
+import com.google.common.base.Preconditions;
+import io.fd.hc2vpp.srv6.write.sid.request.TableLookupLocalSidRequest;
+import io.fd.honeycomb.translate.write.WriteContext;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6._static.rev180301.srv6._static.cfg.Sid;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6.types.rev180301.EndDT6;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6.types.rev180301.Srv6EndpointType;
+
+public class EndDT6FunctionBinder extends TableLookupFunctionBinder {
+
+ public EndDT6FunctionBinder(@Nonnull final FutureJVppCore api) {
+ super(api);
+ }
+
+ @Nonnull
+ @Override
+ public TableLookupLocalSidRequest createWriteRequestAndBind(@Nonnull Sid data,
+ @Nonnull WriteContext ctx) {
+ Preconditions.checkNotNull(data.getEndDt6(), "EndDt6 data cannot be null.");
+ Preconditions.checkNotNull(data.getEndDt6().getLookupTableIpv6(), "EndDt6 lookup table cannot be null.");
+ int lookupTable = data.getEndDt6().getLookupTableIpv6().getValue().intValue();
+ return bindData(new TableLookupLocalSidRequest(getFutureJVpp()), lookupTable, true, ctx);
+ }
+
+ @Override
+ @Nonnull
+ public Class<? extends Srv6EndpointType> getHandledFunctionType() {
+ return EndDT6.class;
+ }
+}
diff --git a/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/lookup/EndTFunctionBinder.java b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/lookup/EndTFunctionBinder.java
new file mode 100644
index 000000000..13a2d3bc7
--- /dev/null
+++ b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/lookup/EndTFunctionBinder.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.srv6.util.function.lookup;
+
+import com.google.common.base.Preconditions;
+import io.fd.hc2vpp.srv6.write.sid.request.TableLookupLocalSidRequest;
+import io.fd.honeycomb.translate.write.WriteContext;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6._static.rev180301.srv6._static.cfg.Sid;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6.types.rev180301.Srv6EndpointType;
+
+public class EndTFunctionBinder extends TableLookupFunctionBinder {
+
+ public EndTFunctionBinder(@Nonnull FutureJVppCore api) {
+ super(api);
+ }
+
+ @Nonnull
+ @Override
+ public TableLookupLocalSidRequest createWriteRequestAndBind(@Nonnull Sid data, @Nonnull WriteContext ctx) {
+ Preconditions.checkNotNull(data.getEndT(), "EndT data cannot be null.");
+ Preconditions.checkNotNull(data.getEndT().getLookupTableIpv6(), "EndT lookup table cannot be null.");
+ int lookupTable = data.getEndT().getLookupTableIpv6().getValue().intValue();
+ return bindData(new TableLookupLocalSidRequest(getFutureJVpp()), lookupTable, true, ctx);
+ }
+
+ @Override
+ @Nonnull
+ public Class<? extends Srv6EndpointType> getHandledFunctionType() {
+ return org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6.types.rev180301.EndT.class;
+ }
+}
diff --git a/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/lookup/TableLookupFunctionBinder.java b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/lookup/TableLookupFunctionBinder.java
new file mode 100644
index 000000000..8e6ab4f40
--- /dev/null
+++ b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/lookup/TableLookupFunctionBinder.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.srv6.util.function.lookup;
+
+import static com.google.common.base.Preconditions.checkState;
+
+import com.google.common.collect.ImmutableMap;
+import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
+import io.fd.hc2vpp.fib.management.FibManagementIIds;
+import io.fd.hc2vpp.srv6.util.function.LocalSidFunctionBinder;
+import io.fd.hc2vpp.srv6.write.sid.request.TableLookupLocalSidRequest;
+import io.fd.honeycomb.translate.write.WriteContext;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import java.util.Map;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6.types.rev180301.EndDT4;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6.types.rev180301.EndDT6;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6.types.rev180301.EndT;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6.types.rev180301.Srv6EndpointType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.fib.table.management.rev180521.AddressFamilyIdentity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.fib.table.management.rev180521.Ipv4;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.fib.table.management.rev180521.Ipv6;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.fib.table.management.rev180521.VniReference;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.fib.table.management.rev180521.vpp.fib.table.management.fib.tables.Table;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.fib.table.management.rev180521.vpp.fib.table.management.fib.tables.TableKey;
+import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
+
+abstract class TableLookupFunctionBinder extends FutureJVppCustomizer
+ implements LocalSidFunctionBinder<TableLookupLocalSidRequest> {
+
+ private static final Map<Class<? extends Srv6EndpointType>, Integer> REGISTER = ImmutableMap.of(
+ EndT.class, 3,
+ EndDT6.class, 8,
+ EndDT4.class, 9
+ );
+
+ TableLookupFunctionBinder(@Nonnull final FutureJVppCore api) {
+ super(api);
+ checkState(REGISTER.containsKey(getHandledFunctionType()),
+ "Unsupported type of Local SID function %s", getHandledFunctionType());
+ }
+
+ TableLookupLocalSidRequest bindData(TableLookupLocalSidRequest request, int tableIndex, final boolean isIpv6,
+ WriteContext ctx) {
+ // verify if the lookup table exists
+ Class<? extends AddressFamilyIdentity> adrFamily = isIpv6 ? Ipv6.class : Ipv4.class;
+ TableKey tableKey = new TableKey(adrFamily, new VniReference(Integer.toUnsignedLong(tableIndex)));
+ KeyedInstanceIdentifier<Table, TableKey> vrfIid = FibManagementIIds.FM_FIB_TABLES.child(Table.class, tableKey);
+ if (!ctx.readAfter(vrfIid).isPresent()) {
+ throw new IllegalArgumentException(
+ String.format("VRF lookup table: %s not found. Binding failed for request: %s", tableKey, request));
+ }
+ request.setLookupFibTable(tableIndex);
+ request.setFunction(getBehaviourFunctionType());
+ return request;
+ }
+
+ @Override
+ public int getBehaviourFunctionType() {
+ return REGISTER.get(getHandledFunctionType());
+ }
+}
diff --git a/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/nofunction/EndFunctionBinder.java b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/nofunction/EndFunctionBinder.java
new file mode 100644
index 000000000..a1952e3c4
--- /dev/null
+++ b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/nofunction/EndFunctionBinder.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.srv6.util.function.nofunction;
+
+import com.google.common.base.Preconditions;
+import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
+import io.fd.hc2vpp.srv6.util.function.LocalSidFunctionBinder;
+import io.fd.hc2vpp.srv6.write.sid.request.NoProtocolLocalSidRequest;
+import io.fd.honeycomb.translate.write.WriteContext;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6._static.rev180301.srv6._static.cfg.Sid;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6.types.rev180301.Srv6EndpointType;
+
+public class EndFunctionBinder extends FutureJVppCustomizer implements
+ LocalSidFunctionBinder<NoProtocolLocalSidRequest> {
+
+ private static final int END_FUNCTION_VALUE = 1;
+
+ public EndFunctionBinder(@Nonnull FutureJVppCore futureJVppCore) {
+ super(futureJVppCore);
+ }
+
+ @Nonnull
+ @Override
+ public NoProtocolLocalSidRequest createWriteRequestAndBind(@Nonnull Sid data,
+ @Nonnull WriteContext ctx) {
+ Preconditions.checkNotNull(data.getEnd(), "End data cannot be null.");
+ NoProtocolLocalSidRequest request = new NoProtocolLocalSidRequest(getFutureJVpp());
+ request.setFunction(END_FUNCTION_VALUE);
+ return request;
+ }
+
+ @Nonnull
+ @Override
+ public Class<? extends Srv6EndpointType> getHandledFunctionType() {
+ return org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6.types.rev180301.End.class;
+ }
+
+ @Override
+ public int getBehaviourFunctionType() {
+ return END_FUNCTION_VALUE;
+ }
+}
diff --git a/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/xconnect/EndDX2FunctionBinder.java b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/xconnect/EndDX2FunctionBinder.java
new file mode 100644
index 000000000..63de40b9c
--- /dev/null
+++ b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/xconnect/EndDX2FunctionBinder.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.srv6.util.function.xconnect;
+
+import com.google.common.base.Preconditions;
+import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.hc2vpp.srv6.write.sid.request.XConnectLocalSidRequest;
+import io.fd.honeycomb.translate.write.WriteContext;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6._static.rev180301.srv6._static.cfg.Sid;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6.types.rev180301.EndDX2;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6.types.rev180301.Srv6EndpointType;
+
+public class EndDX2FunctionBinder extends XConnectFunctionBinder {
+
+ public EndDX2FunctionBinder(@Nonnull final FutureJVppCore api, @Nonnull final NamingContext interfaceContext) {
+ super(api, interfaceContext);
+ }
+
+ @Nonnull
+ @Override
+ public XConnectLocalSidRequest createWriteRequestAndBind(@Nonnull Sid data,
+ @Nonnull WriteContext ctx) {
+ Preconditions.checkNotNull(data.getEndDx2(), "EndDx2 data cannot be null.");
+ Preconditions.checkNotNull(data.getEndDx2().getPaths(), "EndDx2 paths cannot be null.");
+ Preconditions.checkNotNull(data.getEndDx2().getPaths().getInterface(), "EndDx2 Interface cannot be null.");
+ XConnectLocalSidRequest request = new XConnectLocalSidRequest(getFutureJVpp());
+ String outInterface = data.getEndDx2().getPaths().getInterface();
+ Preconditions.checkArgument(outInterface != null && !outInterface.isEmpty(),
+ "Failed to map data: {} for request: {}", data, request);
+ request.setOutgoingInterfaceIndex(getInterfaceIndex(ctx.getMappingContext(), outInterface));
+ request.setFunction(getBehaviourFunctionType());
+ return request;
+ }
+
+ @Nonnull
+ @Override
+ public Class<? extends Srv6EndpointType> getHandledFunctionType() {
+ return EndDX2.class;
+ }
+}
diff --git a/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/xconnect/EndDX4FunctionBinder.java b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/xconnect/EndDX4FunctionBinder.java
new file mode 100644
index 000000000..51abc9876
--- /dev/null
+++ b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/xconnect/EndDX4FunctionBinder.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.srv6.util.function.xconnect;
+
+import com.google.common.base.Preconditions;
+import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.hc2vpp.srv6.write.sid.request.XConnectLocalSidRequest;
+import io.fd.honeycomb.translate.write.WriteContext;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import java.util.Optional;
+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.srv6._static.rev180301.multi.paths.v4.paths.Path;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6._static.rev180301.srv6._static.cfg.Sid;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6.types.rev180301.EndDX4;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6.types.rev180301.Srv6EndpointType;
+
+public class EndDX4FunctionBinder extends XConnectFunctionBinder {
+
+ public EndDX4FunctionBinder(@Nonnull FutureJVppCore api, @Nonnull NamingContext interfaceContext) {
+ super(api, interfaceContext);
+ }
+
+ @Nonnull
+ @Override
+ public XConnectLocalSidRequest createWriteRequestAndBind(@Nonnull Sid data, @Nonnull WriteContext ctx) {
+ XConnectLocalSidRequest request = new XConnectLocalSidRequest(getFutureJVpp());
+ Preconditions.checkNotNull(data.getEndDx4(), "EndDx4 data cannot be null.");
+ Preconditions.checkNotNull(data.getEndDx4().getPaths(), "EndDx4 paths cannot be null.");
+ Preconditions.checkNotNull(data.getEndDx4().getPaths().getPath(), "EndDx4 list of paths cannot be null.");
+ Optional<Path> firstPathOptional = data.getEndDx4().getPaths().getPath().stream().findFirst();
+ Preconditions
+ .checkArgument(firstPathOptional.isPresent(), "Failed to map data: {} for request: {}", data, request);
+ request.setOutgoingInterfaceIndex(
+ getInterfaceIndex(ctx.getMappingContext(), firstPathOptional.get().getInterface()));
+ request.setNextHopAddress(new IpAddress(firstPathOptional.get().getNextHop()));
+ request.setFunction(getBehaviourFunctionType());
+ return request;
+ }
+
+ @Nonnull
+ @Override
+ public Class<? extends Srv6EndpointType> getHandledFunctionType() {
+ return EndDX4.class;
+ }
+}
diff --git a/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/xconnect/EndDX6FunctionBinder.java b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/xconnect/EndDX6FunctionBinder.java
new file mode 100644
index 000000000..71194fbd4
--- /dev/null
+++ b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/xconnect/EndDX6FunctionBinder.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.srv6.util.function.xconnect;
+
+import com.google.common.base.Preconditions;
+import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.hc2vpp.srv6.write.sid.request.XConnectLocalSidRequest;
+import io.fd.honeycomb.translate.write.WriteContext;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import java.util.Optional;
+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.srv6._static.rev180301.multi.paths.v6.paths.Path;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6._static.rev180301.srv6._static.cfg.Sid;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6.types.rev180301.EndDX6;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6.types.rev180301.Srv6EndpointType;
+
+public class EndDX6FunctionBinder extends XConnectFunctionBinder {
+
+ public EndDX6FunctionBinder(@Nonnull FutureJVppCore api, @Nonnull NamingContext interfaceContext) {
+ super(api, interfaceContext);
+ }
+
+ @Nonnull
+ @Override
+ public XConnectLocalSidRequest createWriteRequestAndBind(@Nonnull Sid data, @Nonnull WriteContext ctx) {
+ XConnectLocalSidRequest request = new XConnectLocalSidRequest(getFutureJVpp());
+ Preconditions.checkNotNull(data.getEndDx6(), "EndDx6 data cannot be null.");
+ Preconditions.checkNotNull(data.getEndDx6().getPaths(), "EndDx6 paths cannot be null.");
+ Preconditions.checkNotNull(data.getEndDx6().getPaths().getPath(), "EndDx6 list of paths cannot be null.");
+ Optional<Path> firstPathOptional = data.getEndDx6().getPaths().getPath().stream().findFirst();
+ Preconditions
+ .checkArgument(firstPathOptional.isPresent(), "Failed to map data: {} for request: {}", data, request);
+ request.setOutgoingInterfaceIndex(
+ getInterfaceIndex(ctx.getMappingContext(), firstPathOptional.get().getInterface()));
+ request.setNextHopAddress(new IpAddress(firstPathOptional.get().getNextHop()));
+ request.setFunction(getBehaviourFunctionType());
+ return request;
+ }
+
+ @Nonnull
+ @Override
+ public Class<? extends Srv6EndpointType> getHandledFunctionType() {
+ return EndDX6.class;
+ }
+}
diff --git a/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/xconnect/EndXFunctionBinder.java b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/xconnect/EndXFunctionBinder.java
new file mode 100644
index 000000000..0b3af395c
--- /dev/null
+++ b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/xconnect/EndXFunctionBinder.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.srv6.util.function.xconnect;
+
+import com.google.common.base.Preconditions;
+import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.hc2vpp.srv6.write.sid.request.XConnectLocalSidRequest;
+import io.fd.honeycomb.translate.write.WriteContext;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import java.util.Optional;
+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.srv6._static.rev180301.multi.paths.v6.paths.Path;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6._static.rev180301.srv6._static.cfg.Sid;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6.types.rev180301.Srv6EndpointType;
+
+public class EndXFunctionBinder extends XConnectFunctionBinder {
+
+ public EndXFunctionBinder(@Nonnull FutureJVppCore api, @Nonnull NamingContext interfaceContext) {
+ super(api, interfaceContext);
+ }
+
+ @Nonnull
+ @Override
+ public XConnectLocalSidRequest createWriteRequestAndBind(@Nonnull Sid data,
+ @Nonnull WriteContext ctx) {
+ XConnectLocalSidRequest request = new XConnectLocalSidRequest(getFutureJVpp());
+ Preconditions.checkNotNull(data.getEndX(), "EndX data cannot be null.");
+ Preconditions.checkNotNull(data.getEndX().getPaths(), "EndX paths cannot be null.");
+ Preconditions.checkNotNull(data.getEndX().getPaths().getPath(), "EndX list of paths cannot be null.");
+ Optional<Path> firstPathOptional = data.getEndX().getPaths().getPath().stream().findFirst();
+ Preconditions
+ .checkArgument(firstPathOptional.isPresent(), "Failed to map data: {} for request: {}", data, request);
+
+ request.setOutgoingInterfaceIndex(
+ getInterfaceIndex(ctx.getMappingContext(), firstPathOptional.get().getInterface()));
+ request.setNextHopAddress(new IpAddress(firstPathOptional.get().getNextHop()));
+ request.setFunction(getBehaviourFunctionType());
+ return request;
+ }
+
+ @Nonnull
+ @Override
+ public Class<? extends Srv6EndpointType> getHandledFunctionType() {
+ return org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6.types.rev180301.EndX.class;
+ }
+}
diff --git a/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/xconnect/XConnectFunctionBinder.java b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/xconnect/XConnectFunctionBinder.java
new file mode 100644
index 000000000..9f69c9041
--- /dev/null
+++ b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/util/function/xconnect/XConnectFunctionBinder.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.srv6.util.function.xconnect;
+
+import static com.google.common.base.Preconditions.checkState;
+import static java.lang.String.format;
+
+import com.google.common.collect.ImmutableMap;
+import io.fd.hc2vpp.common.translate.util.AddressTranslator;
+import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
+import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.hc2vpp.srv6.util.function.LocalSidFunctionBinder;
+import io.fd.hc2vpp.srv6.write.sid.request.XConnectLocalSidRequest;
+import io.fd.honeycomb.translate.MappingContext;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import java.util.Map;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6.types.rev180301.EndDX2;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6.types.rev180301.EndDX4;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6.types.rev180301.EndDX6;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6.types.rev180301.EndX;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6.types.rev180301.Srv6EndpointType;
+
+abstract class XConnectFunctionBinder extends FutureJVppCustomizer
+ implements LocalSidFunctionBinder<XConnectLocalSidRequest>, AddressTranslator {
+
+ private static final Map<Class<? extends Srv6EndpointType>, Integer>
+ REGISTER = ImmutableMap.of(EndX.class, 2,
+ EndDX2.class, 5,
+ EndDX4.class, 7,
+ EndDX6.class, 6);
+
+ private final NamingContext interfaceContext;
+
+ XConnectFunctionBinder(@Nonnull final FutureJVppCore api, @Nonnull final NamingContext interfaceContext) {
+ super(api);
+ this.interfaceContext = interfaceContext;
+ checkState(REGISTER.containsKey(getHandledFunctionType()), "Unsupported type of Local SID function %s",
+ getHandledFunctionType());
+ }
+
+ @Override
+ public int getBehaviourFunctionType() {
+ return REGISTER.get(getHandledFunctionType());
+ }
+
+ int getInterfaceIndex(final MappingContext ctx, final String name) {
+ return interfaceContext.getIndex(name, ctx, () -> new IllegalArgumentException(
+ format("Interface with name %s not found", name)));
+ }
+}
diff --git a/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/DeleteRequest.java b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/DeleteRequest.java
new file mode 100644
index 000000000..bd48e25df
--- /dev/null
+++ b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/DeleteRequest.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.srv6.write;
+
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public interface DeleteRequest {
+
+ void delete(final InstanceIdentifier<?> identifier) throws WriteFailedException;
+}
diff --git a/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/Srv6Customizer.java b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/Srv6Customizer.java
new file mode 100644
index 000000000..a9cb8405d
--- /dev/null
+++ b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/Srv6Customizer.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package io.fd.hc2vpp.srv6.write;
+
+import io.fd.honeycomb.translate.spi.write.WriterCustomizer;
+import io.fd.honeycomb.translate.write.WriteContext;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6.base.rev180301.routing.Srv6;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class Srv6Customizer implements WriterCustomizer<Srv6> {
+ private static final Logger LOG = LoggerFactory.getLogger(Srv6Customizer.class);
+
+ @Override
+ public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<Srv6> instanceIdentifier,
+ @Nonnull final Srv6 srv6,
+ @Nonnull final WriteContext writeContext) throws WriteFailedException {
+ LOG.debug("Writing SRV6 configuration is not supported by VPP. SRV6 is always enabled");
+ throw new WriteFailedException.CreateFailedException(instanceIdentifier, srv6,
+ new UnsupportedOperationException("Changing SRV6 configuration is not supported by VPP."));
+ }
+
+ @Override
+ public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<Srv6> instanceIdentifier,
+ @Nonnull final Srv6 srv6,
+ @Nonnull final WriteContext writeContext) throws WriteFailedException {
+ LOG.debug("Deleting SRV6 configuration is not supported by VPP. SRV6 is always enabled");
+ throw new WriteFailedException.DeleteFailedException(instanceIdentifier,
+ new UnsupportedOperationException("Changing SRV6 configuration is not supported by VPP."));
+ }
+}
diff --git a/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/Srv6WriterFactory.java b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/Srv6WriterFactory.java
new file mode 100644
index 000000000..5dea50f48
--- /dev/null
+++ b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/Srv6WriterFactory.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.srv6.write;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Inject;
+import io.fd.hc2vpp.srv6.Srv6IIds;
+import io.fd.hc2vpp.srv6.util.function.LocalSidFunctionWriteBindingRegistry;
+import io.fd.hc2vpp.srv6.write.encap.source.EncapsulationSourceCustomizer;
+import io.fd.hc2vpp.srv6.write.sid.LocatorCustomizer;
+import io.fd.hc2vpp.srv6.write.sid.SidCustomizer;
+import io.fd.honeycomb.translate.impl.write.GenericListWriter;
+import io.fd.honeycomb.translate.impl.write.GenericWriter;
+import io.fd.honeycomb.translate.write.WriterFactory;
+import io.fd.honeycomb.translate.write.registry.ModifiableWriterRegistryBuilder;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import javax.annotation.Nonnull;
+
+public class Srv6WriterFactory implements WriterFactory {
+
+ @Inject
+ private FutureJVppCore futureJVppCore;
+ @Inject
+ private LocalSidFunctionWriteBindingRegistry bindingRegistry;
+
+ @Override
+ public void init(@Nonnull final ModifiableWriterRegistryBuilder registry) {
+
+ registry.add(new GenericWriter<>(Srv6IIds.RT_SRV6, new Srv6Customizer()));
+
+ registry.subtreeAdd(ImmutableSet.of(Srv6IIds.LOC_PREFIX, Srv6IIds.LOC_FT_AUG, Srv6IIds.LOC_FT),
+ new GenericWriter<>(Srv6IIds.RT_SRV6_LOCS_LOCATOR, new LocatorCustomizer(futureJVppCore)));
+
+ registry.add(new GenericWriter<>(Srv6IIds.RT_SRV6_ENCAP, new EncapsulationSourceCustomizer(futureJVppCore)));
+
+ registry.subtreeAdd(ImmutableSet
+ .of(Srv6IIds.SID_END, Srv6IIds.SID_END_X, Srv6IIds.SID_END_X_PATHS, Srv6IIds.SID_END_X_PATHS_PATH,
+ Srv6IIds.SID_END_T, Srv6IIds.SID_END_B6, Srv6IIds.SID_END_B6ENCAP, Srv6IIds.SID_END_BM,
+ Srv6IIds.SID_END_DT4, Srv6IIds.SID_END_DT6, Srv6IIds.SID_END_DT46, Srv6IIds.SID_END_DX2,
+ Srv6IIds.SID_END_DX4, Srv6IIds.SID_END_DX6, Srv6IIds.SID_END_DX6_PATHS,
+ Srv6IIds.SID_END_DX6_PATHS_PATH, Srv6IIds.SID_END_DX4_PATHS, Srv6IIds.SID_END_DX4_PATHS_PATH,
+ Srv6IIds.SID_END_DX2_PATHS), new GenericListWriter<>(Srv6IIds.RT_SRV6_LOCS_LOC_ST_LS_SID,
+ new SidCustomizer(futureJVppCore, bindingRegistry)));
+ }
+}
diff --git a/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/UpdateRequest.java b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/UpdateRequest.java
new file mode 100644
index 000000000..545c1d24f
--- /dev/null
+++ b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/UpdateRequest.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.srv6.write;
+
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public interface UpdateRequest {
+
+ void update(final InstanceIdentifier<?> identifier) throws WriteFailedException;
+}
diff --git a/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/WriteRequest.java b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/WriteRequest.java
new file mode 100644
index 000000000..f083c4ab8
--- /dev/null
+++ b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/WriteRequest.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.srv6.write;
+
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public interface WriteRequest {
+
+ void write(final InstanceIdentifier<?> identifier) throws WriteFailedException;
+}
diff --git a/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/encap/source/EncapsulationSourceCustomizer.java b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/encap/source/EncapsulationSourceCustomizer.java
new file mode 100644
index 000000000..375aad0f9
--- /dev/null
+++ b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/encap/source/EncapsulationSourceCustomizer.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.srv6.write.encap.source;
+
+import com.google.common.annotations.VisibleForTesting;
+import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
+import io.fd.hc2vpp.srv6.write.encap.source.request.EncapsulationSourceDeleteRequest;
+import io.fd.hc2vpp.srv6.write.encap.source.request.EncapsulationSourceWriteRequest;
+import io.fd.honeycomb.translate.spi.write.WriterCustomizer;
+import io.fd.honeycomb.translate.write.WriteContext;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6.base.rev180301.srv6.encap.Encapsulation;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class EncapsulationSourceCustomizer extends FutureJVppCustomizer implements WriterCustomizer<Encapsulation> {
+
+ public EncapsulationSourceCustomizer(@Nonnull FutureJVppCore futureJVppCore) {
+ super(futureJVppCore);
+ }
+
+ @Override
+ public void writeCurrentAttributes(@Nonnull InstanceIdentifier<Encapsulation> instanceIdentifier,
+ @Nonnull Encapsulation encapsulation, @Nonnull WriteContext writeContext)
+ throws WriteFailedException {
+ bindEncapsulationSourceWriteRequest(encapsulation).write(instanceIdentifier);
+
+ }
+
+ private EncapsulationSourceWriteRequest bindEncapsulationSourceWriteRequest(Encapsulation encapsulation) {
+ return new EncapsulationSourceWriteRequest(getFutureJVpp()).setBsid(encapsulation.getSourceAddress());
+ }
+
+ @Override
+ public void deleteCurrentAttributes(@Nonnull InstanceIdentifier<Encapsulation> instanceIdentifier,
+ @Nonnull Encapsulation encapsulation, @Nonnull WriteContext writeContext)
+ throws WriteFailedException {
+ bindEncapsulationSourceDeleteRequest().delete(instanceIdentifier);
+ }
+
+ @VisibleForTesting
+ private EncapsulationSourceDeleteRequest bindEncapsulationSourceDeleteRequest() {
+ return new EncapsulationSourceDeleteRequest(getFutureJVpp());
+ }
+}
diff --git a/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/encap/source/request/EncapsulationSourceDeleteRequest.java b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/encap/source/request/EncapsulationSourceDeleteRequest.java
new file mode 100644
index 000000000..e8877a956
--- /dev/null
+++ b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/encap/source/request/EncapsulationSourceDeleteRequest.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.srv6.write.encap.source.request;
+
+import io.fd.hc2vpp.srv6.util.JVppRequest;
+import io.fd.hc2vpp.srv6.write.DeleteRequest;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import io.fd.vpp.jvpp.core.dto.SrSetEncapSource;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class EncapsulationSourceDeleteRequest extends JVppRequest implements DeleteRequest {
+
+ public EncapsulationSourceDeleteRequest(final FutureJVppCore api) {
+ super(api);
+ }
+
+ @Override
+ public void delete(InstanceIdentifier<?> identifier) throws WriteFailedException {
+ checkValid();
+ final SrSetEncapSource request = new SrSetEncapSource();
+ request.encapsSource = null;
+ getReplyForDelete(getApi().srSetEncapSource(request).toCompletableFuture(), identifier);
+ }
+}
diff --git a/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/encap/source/request/EncapsulationSourceWriteRequest.java b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/encap/source/request/EncapsulationSourceWriteRequest.java
new file mode 100644
index 000000000..0ecf13108
--- /dev/null
+++ b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/encap/source/request/EncapsulationSourceWriteRequest.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.srv6.write.encap.source.request;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import io.fd.hc2vpp.srv6.util.JVppRequest;
+import io.fd.hc2vpp.srv6.write.WriteRequest;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import io.fd.vpp.jvpp.core.dto.SrSetEncapSource;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class EncapsulationSourceWriteRequest extends JVppRequest implements WriteRequest {
+
+ private Ipv6Address bsid;
+
+ public EncapsulationSourceWriteRequest(final FutureJVppCore api) {
+ super(api);
+ }
+
+ @Override
+ public void checkValid() {
+ checkNotNull(bsid, "Binding SID must be set");
+ }
+
+ public Ipv6Address getBsid() {
+ return bsid;
+ }
+
+ public EncapsulationSourceWriteRequest setBsid(final Ipv6Address bsid) {
+ this.bsid = bsid;
+ return this;
+ }
+
+ @Override
+ public void write(final InstanceIdentifier<?> identifier) throws WriteFailedException {
+ checkValid();
+ final SrSetEncapSource request = new SrSetEncapSource();
+ request.encapsSource = ipv6AddressNoZoneToArray(bsid);
+ getReplyForWrite(getApi().srSetEncapSource(request).toCompletableFuture(), identifier);
+ }
+}
diff --git a/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/sid/LocatorCustomizer.java b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/sid/LocatorCustomizer.java
new file mode 100644
index 000000000..86ab3599c
--- /dev/null
+++ b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/sid/LocatorCustomizer.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.srv6.write.sid;
+
+import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
+import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
+import io.fd.honeycomb.translate.write.WriteContext;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6.base.rev180301.srv6.locators.locators.Locator;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6.base.rev180301.srv6.locators.locators.LocatorKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class LocatorCustomizer extends FutureJVppCustomizer implements ListWriterCustomizer<Locator, LocatorKey> {
+
+ public LocatorCustomizer(@Nonnull final FutureJVppCore futureJVppCore) {
+ super(futureJVppCore);
+ }
+
+ @Override
+ public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<Locator> instanceIdentifier,
+ @Nonnull final Locator locator, @Nonnull final WriteContext writeContext) {
+ // noop
+ }
+
+ @Override
+ public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<Locator> instanceIdentifier,
+ @Nonnull final Locator locator, @Nonnull final WriteContext writeContext) {
+ // noop
+ }
+}
diff --git a/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/sid/SidCustomizer.java b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/sid/SidCustomizer.java
new file mode 100644
index 000000000..c63205699
--- /dev/null
+++ b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/sid/SidCustomizer.java
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.srv6.write.sid;
+
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import com.googlecode.ipv6.IPv6NetworkMask;
+import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
+import io.fd.hc2vpp.fib.management.FibManagementIIds;
+import io.fd.hc2vpp.srv6.util.function.LocalSidFunctionWriteBindingRegistry;
+import io.fd.hc2vpp.srv6.write.sid.request.LocalSidFunctionRequest;
+import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
+import io.fd.honeycomb.translate.util.RWUtils;
+import io.fd.honeycomb.translate.write.WriteContext;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.hc2vpp.params.xml.ns.yang.vpp.ietf.srv6.base.rev180613.VppSrv6FibLocatorAugment;
+import org.opendaylight.yang.gen.v1.urn.hc2vpp.params.xml.ns.yang.vpp.ietf.srv6.base.rev180613.vpp.srv6.fib.FibTable;
+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.srv6._static.rev180301.srv6._static.cfg.Sid;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6._static.rev180301.srv6._static.cfg.SidKey;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6.base.rev180301.srv6.locators.locators.Locator;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.srv6.base.rev180301.srv6.locators.locators.locator.Prefix;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.fib.table.management.rev180521.vpp.fib.table.management.fib.tables.Table;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.fib.table.management.rev180521.vpp.fib.table.management.fib.tables.TableKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
+
+public class SidCustomizer extends FutureJVppCustomizer implements ListWriterCustomizer<Sid, SidKey> {
+
+ private final LocalSidFunctionWriteBindingRegistry bindingRegistry;
+
+ public SidCustomizer(@Nonnull final FutureJVppCore futureJVppCore,
+ @Nonnull final LocalSidFunctionWriteBindingRegistry bindingRegistry) {
+ super(futureJVppCore);
+ this.bindingRegistry = bindingRegistry;
+ }
+
+ Ipv6Address resolveSidAddress(@Nonnull final Prefix locPrefix, @Nonnull Sid localSid) {
+ com.googlecode.ipv6.IPv6Address ip =
+ com.googlecode.ipv6.IPv6Address.fromString(locPrefix.getAddress().getValue());
+ IPv6NetworkMask mask = IPv6NetworkMask.fromPrefixLength(locPrefix.getLength().getValue());
+ // strip function part if present
+ ip = ip.maskWithNetworkMask(mask);
+ //add new function part based on opcode
+ String locIp = ip.add(localSid.getOpcode().getValue().intValue()).toString();
+ return new Ipv6Address(locIp);
+ }
+
+ @Override
+ public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<Sid> instanceIdentifier,
+ @Nonnull final Sid localSid, @Nonnull final WriteContext writeContext)
+ throws WriteFailedException {
+ InstanceIdentifier<Locator> locatorIid = RWUtils.cutId(instanceIdentifier, Locator.class);
+ Optional<Locator> locatorOpt = writeContext.readAfter(locatorIid);
+ Table vrfTable = getVrfTable(instanceIdentifier, writeContext, locatorIid, locatorOpt);
+ LocalSidFunctionRequest request = bindRequest(extractLocPrefix(instanceIdentifier, locatorOpt, localSid),
+ localSid, vrfTable.getTableId().getValue().intValue(), writeContext);
+ if (request == null) {
+ throw new WriteFailedException(instanceIdentifier,
+ String.format("Cannot create write request for %s", localSid));
+ }
+ request.write(instanceIdentifier);
+ }
+
+ private Table getVrfTable(final @Nonnull InstanceIdentifier<Sid> iid, final @Nonnull WriteContext writeContext,
+ final InstanceIdentifier<Locator> locatorIid, final Optional<Locator> locatorOpt) {
+ Preconditions.checkArgument(locatorOpt.isPresent(), "Locator: {} for SID: {} was not found.", locatorIid, iid);
+ Preconditions.checkNotNull(locatorOpt.get().getAugmentation(VppSrv6FibLocatorAugment.class),
+ "Vpp FIB table augmentation was not found for SID: {}.", iid);
+ FibTable fibTable = locatorOpt.get().getAugmentation(VppSrv6FibLocatorAugment.class).getFibTable();
+ Preconditions.checkNotNull(fibTable, "Vpp FIB table configuration was not found for SID: {}.", iid);
+ TableKey tableKey = new TableKey(fibTable.getAddressFamily(), fibTable.getTableId());
+ KeyedInstanceIdentifier<Table, TableKey> vrfIid = FibManagementIIds.FM_FIB_TABLES.child(Table.class, tableKey);
+ if (!writeContext.readAfter(vrfIid).isPresent()) {
+ throw new IllegalArgumentException(
+ String.format("VRF table: %s not found. Create table before writing SID : %s.", tableKey, iid));
+ }
+ return writeContext.readAfter(vrfIid).get();
+ }
+
+ private Prefix extractLocPrefix(final @Nonnull InstanceIdentifier<Sid> instanceIdentifier,
+ Optional<Locator> locatorOpt, final @Nonnull Sid localSid)
+ throws WriteFailedException {
+ Preconditions.checkArgument(locatorOpt.isPresent(), "Cannot read locator for sid: {}, with IId: ", localSid,
+ instanceIdentifier);
+ Locator loc = locatorOpt.get();
+ if (loc.getPrefix() == null || loc.getPrefix() == null || loc.getPrefix().getAddress() == null ||
+ loc.getPrefix().getLength() == null) {
+ throw new WriteFailedException(instanceIdentifier,
+ String.format("Cannot parse locator prefix for local sid %s", localSid));
+ }
+ return loc.getPrefix();
+ }
+
+ @Override
+ public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<Sid> instanceIdentifier,
+ @Nonnull final Sid localSid, @Nonnull final WriteContext writeContext)
+ throws WriteFailedException {
+ InstanceIdentifier<Locator> locatorIid = RWUtils.cutId(instanceIdentifier, Locator.class);
+ Optional<Locator> locatorOpt = writeContext.readBefore(locatorIid);
+ Table vrfTable = getVrfTable(instanceIdentifier, writeContext, locatorIid, locatorOpt);
+ LocalSidFunctionRequest request = bindRequest(extractLocPrefix(instanceIdentifier, locatorOpt, localSid),
+ localSid, vrfTable.getTableId().getValue().intValue(), writeContext);
+
+ if (request == null) {
+ throw new WriteFailedException(instanceIdentifier,
+ String.format("Cannot create delete request for %s", localSid));
+ }
+ request.delete(instanceIdentifier);
+ }
+
+ private LocalSidFunctionRequest bindRequest(final @Nonnull Prefix locPrefix, final @Nonnull Sid localSid,
+ final int installFibId, final @Nonnull WriteContext writeContext) {
+ LocalSidFunctionRequest request = bindingRegistry.bind(localSid, writeContext);
+ Ipv6Address sidAddress = resolveSidAddress(locPrefix, localSid);
+ request.setLocalSidAddress(sidAddress);
+ request.setInstallFibTable(installFibId);
+ return request;
+ }
+}
diff --git a/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/sid/request/LocalSidFunctionRequest.java b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/sid/request/LocalSidFunctionRequest.java
new file mode 100644
index 000000000..e3d64ea6c
--- /dev/null
+++ b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/sid/request/LocalSidFunctionRequest.java
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.srv6.write.sid.request;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+
+import io.fd.hc2vpp.srv6.util.JVppRequest;
+import io.fd.hc2vpp.srv6.write.DeleteRequest;
+import io.fd.hc2vpp.srv6.write.WriteRequest;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import io.fd.vpp.jvpp.core.dto.SrLocalsidAddDel;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import io.fd.vpp.jvpp.core.types.Srv6Sid;
+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.srv6._static.rev180301.Srv6SidConfig;
+import org.opendaylight.yangtools.yang.binding.ChildOf;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+/**
+ * General template for Local SID requests
+ */
+public abstract class LocalSidFunctionRequest<O extends ChildOf<Srv6SidConfig>> extends JVppRequest
+ implements WriteRequest, DeleteRequest {
+
+ /**
+ * Local SID
+ */
+ private Ipv6Address localSidAddress;
+
+ /**
+ * FIB table where Local SID will be installed
+ */
+ private int installFibTable;
+
+ /**
+ * Function that will be used for this Local SID
+ */
+ private int function;
+
+ /**
+ * Whether this node should remove segment routing header for incoming packets
+ */
+ private boolean isPsp;
+
+ LocalSidFunctionRequest(final FutureJVppCore api) {
+ super(api);
+ //Default behaviour is PSP. END,END.T and END.X function can set USP=true -> PSP=false
+ isPsp = true;
+ }
+
+ protected void bindRequest(final SrLocalsidAddDel request) {
+ Srv6Sid srv6Sid = new Srv6Sid();
+ srv6Sid.addr = ipv6AddressNoZoneToArray(getLocalSidAddress());
+ request.localsid = srv6Sid;
+ request.behavior = (byte) getFunction();
+ request.fibTable = getInstallFibTable();
+ request.endPsp = booleanToByte(isPsp());
+ }
+
+ @Override
+ public void checkValid() {
+ checkNotNull(getLocalSidAddress(), "Sid address not set");
+ checkState(getFunction() != 0, "No behavior set");
+ }
+
+ @Override
+ public void write(final InstanceIdentifier<?> identifier) throws WriteFailedException {
+ checkValid();
+
+ final SrLocalsidAddDel request = new SrLocalsidAddDel();
+ request.isDel = 0;
+ bindRequest(request);
+
+ getReplyForWrite(getApi().srLocalsidAddDel(request).toCompletableFuture(), identifier);
+ }
+
+ @Override
+ public void delete(final InstanceIdentifier<?> identifier) throws WriteFailedException {
+ checkValid();
+
+ final SrLocalsidAddDel request = new SrLocalsidAddDel();
+ request.isDel = 1;
+ bindRequest(request);
+ getReplyForDelete(getApi().srLocalsidAddDel(request).toCompletableFuture(), identifier);
+ }
+
+ public Ipv6Address getLocalSidAddress() {
+ return localSidAddress;
+ }
+
+ public void setLocalSidAddress(final Ipv6Address localSidAddress) {
+ this.localSidAddress = localSidAddress;
+ }
+
+ public int getInstallFibTable() {
+ return installFibTable;
+ }
+
+ public void setInstallFibTable(final int installFibTable) {
+ this.installFibTable = installFibTable;
+ }
+
+ public int getFunction() {
+ return function;
+ }
+
+ public void setFunction(final int function) {
+ this.function = function;
+ }
+
+ public boolean isPsp() {
+ return isPsp;
+ }
+
+ public void setPsp(final boolean psp) {
+ isPsp = psp;
+ }
+}
diff --git a/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/sid/request/NoProtocolLocalSidRequest.java b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/sid/request/NoProtocolLocalSidRequest.java
new file mode 100644
index 000000000..18630ccc2
--- /dev/null
+++ b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/sid/request/NoProtocolLocalSidRequest.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.srv6.write.sid.request;
+
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+
+/**
+ * Local SID using End function
+ */
+public class NoProtocolLocalSidRequest extends LocalSidFunctionRequest {
+
+ public NoProtocolLocalSidRequest(final FutureJVppCore api) {
+ super(api);
+ }
+}
diff --git a/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/sid/request/TableLookupLocalSidRequest.java b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/sid/request/TableLookupLocalSidRequest.java
new file mode 100644
index 000000000..4642b3349
--- /dev/null
+++ b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/sid/request/TableLookupLocalSidRequest.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.srv6.write.sid.request;
+
+import io.fd.vpp.jvpp.core.dto.SrLocalsidAddDel;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+
+/**
+ * Request for Local SID using table lookup functions
+ */
+public class TableLookupLocalSidRequest extends LocalSidFunctionRequest {
+
+ /**
+ * FIB table where table lookup should be performed
+ */
+ private int lookupFibTable;
+
+ public TableLookupLocalSidRequest(final FutureJVppCore api) {
+ super(api);
+ }
+
+ @Override
+ protected void bindRequest(final SrLocalsidAddDel request) {
+ super.bindRequest(request);
+ request.swIfIndex = getLookupFibTable();
+ }
+
+ public int getLookupFibTable() {
+ return lookupFibTable;
+ }
+
+ public void setLookupFibTable(final int lookupFibTable) {
+ this.lookupFibTable = lookupFibTable;
+ }
+}
diff --git a/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/sid/request/XConnectLocalSidRequest.java b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/sid/request/XConnectLocalSidRequest.java
new file mode 100644
index 000000000..38208aaf1
--- /dev/null
+++ b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write/sid/request/XConnectLocalSidRequest.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.srv6.write.sid.request;
+
+import io.fd.hc2vpp.common.translate.util.AddressTranslator;
+import io.fd.vpp.jvpp.core.dto.SrLocalsidAddDel;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
+
+/**
+ * Request for Local SID that should use x-connect functions
+ */
+public class XConnectLocalSidRequest extends LocalSidFunctionRequest {
+
+ /**
+ * L2 interface that should be use for forwarding traffic
+ */
+ private int outgoingInterfaceIndex;
+
+ /**
+ * Outgoing VLan tag
+ */
+ private int vlanIndex;
+
+ /**
+ * Address of the next hop
+ */
+ private IpAddress nextHopAddress;
+
+ public XConnectLocalSidRequest(final FutureJVppCore api) {
+ super(api);
+ }
+
+ @Override
+ protected void bindRequest(final SrLocalsidAddDel request) {
+ super.bindRequest(request);
+ request.swIfIndex = getOutgoingInterfaceIndex();
+ request.vlanIndex = getVlanIndex();
+ if (getNextHopAddress() != null) {
+ if (AddressTranslator.INSTANCE.isIpv6(getNextHopAddress())) {
+ request.nhAddr6 = ipAddressToArray(getNextHopAddress());
+ } else {
+ request.nhAddr4 = ipAddressToArray(getNextHopAddress());
+
+ }
+
+ }
+ }
+
+ public int getOutgoingInterfaceIndex() {
+ return outgoingInterfaceIndex;
+ }
+
+ public void setOutgoingInterfaceIndex(final int outgoingInterfaceIndex) {
+ this.outgoingInterfaceIndex = outgoingInterfaceIndex;
+ }
+
+ public int getVlanIndex() {
+ return vlanIndex;
+ }
+
+ public void setVlanIndex(final int vlanIndex) {
+ this.vlanIndex = vlanIndex;
+ }
+
+ public IpAddress getNextHopAddress() {
+ return nextHopAddress;
+ }
+
+ public void setNextHopAddress(final IpAddress nextHopAddress) {
+ this.nextHopAddress = nextHopAddress;
+ }
+}