summaryrefslogtreecommitdiffstats
path: root/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write
diff options
context:
space:
mode:
Diffstat (limited to 'srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/write')
-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
14 files changed, 819 insertions, 0 deletions
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;
+ }
+}