summaryrefslogtreecommitdiffstats
path: root/l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv6
diff options
context:
space:
mode:
Diffstat (limited to 'l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv6')
-rw-r--r--l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv6/Ipv6AddressCustomizer.java92
-rw-r--r--l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv6/Ipv6Customizer.java55
-rw-r--r--l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv6/Ipv6NeighbourCustomizer.java115
-rw-r--r--l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv6/nd/NdProxyCustomizer.java94
-rw-r--r--l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv6/subinterface/SubInterfaceIpv6AddressCustomizer.java73
-rw-r--r--l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv6/subinterface/SubInterfaceIpv6NeighbourCustomizer.java99
6 files changed, 528 insertions, 0 deletions
diff --git a/l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv6/Ipv6AddressCustomizer.java b/l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv6/Ipv6AddressCustomizer.java
new file mode 100644
index 000000000..d6b357c90
--- /dev/null
+++ b/l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv6/Ipv6AddressCustomizer.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2017 Cisco 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.l3.write.ipv6;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
+import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.hc2vpp.l3.utils.ip.write.IpWriter;
+import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
+import io.fd.honeycomb.translate.write.WriteContext;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv6.Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv6.AddressKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class Ipv6AddressCustomizer extends FutureJVppCustomizer
+ implements ListWriterCustomizer<Address, AddressKey>, IpWriter {
+
+ private static final Logger LOG = LoggerFactory.getLogger(Ipv6AddressCustomizer.class);
+
+ private static final String LINK_LOCAL_START_MASK = "fe08";
+ private final NamingContext interfaceContext;
+
+ public Ipv6AddressCustomizer(@Nonnull final FutureJVppCore futureJVppCore,
+ @Nonnull final NamingContext interfaceContext) {
+ super(futureJVppCore);
+ this.interfaceContext = checkNotNull(interfaceContext, "Interface context cannot be null");
+ }
+
+ @Override
+ public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<Address> id, @Nonnull final Address dataAfter,
+ @Nonnull final WriteContext writeContext) throws WriteFailedException {
+ final String interfaceName = id.firstKeyOf(Interface.class).getName();
+ final int interfaceIndex = interfaceContext.getIndex(interfaceName, writeContext.getMappingContext());
+
+ // prevents scenario
+ // - vpp has been restarted == cleaned state
+ // - hc tries to restore data, which has link-local address in it
+ // link layer address is created by vpp(generated) after adding first address, so its present just
+ // after adding first address, and attempt to override it during init would cause error -1
+ if (dataAfter.getIp().getValue().startsWith(LINK_LOCAL_START_MASK)) {
+ LOG.info("An attempt to rewrite link-local address with {} has been detected,ignoring request",
+ dataAfter.getIp());
+ return;
+ }
+
+ addDelAddress(getFutureJVpp(), true, id, interfaceIndex, dataAfter.getIp(),
+ dataAfter.getPrefixLength().byteValue());
+ }
+
+ @Override
+ public void updateCurrentAttributes(@Nonnull final InstanceIdentifier<Address> id,
+ @Nonnull final Address dataBefore,
+ @Nonnull final Address dataAfter, @Nonnull final WriteContext writeContext)
+ throws WriteFailedException {
+ throw new WriteFailedException.UpdateFailedException(id, dataBefore, dataAfter,
+ new UnsupportedOperationException("Operation not supported"));
+ }
+
+ @Override
+ public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<Address> id,
+ @Nonnull final Address dataBefore,
+ @Nonnull final WriteContext writeContext) throws WriteFailedException {
+ final String interfaceName = id.firstKeyOf(Interface.class).getName();
+ final int interfaceIndex = interfaceContext.getIndex(interfaceName, writeContext.getMappingContext());
+
+ addDelAddress(getFutureJVpp(), false, id, interfaceIndex, dataBefore.getIp(),
+ dataBefore.getPrefixLength().byteValue());
+ }
+
+}
diff --git a/l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv6/Ipv6Customizer.java b/l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv6/Ipv6Customizer.java
new file mode 100644
index 000000000..6194dfd4f
--- /dev/null
+++ b/l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv6/Ipv6Customizer.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2017 Cisco 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.l3.write.ipv6;
+
+import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
+import io.fd.honeycomb.translate.spi.write.WriterCustomizer;
+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.ip.rev140616.interfaces._interface.Ipv6;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class Ipv6Customizer extends FutureJVppCustomizer implements WriterCustomizer<Ipv6> {
+
+ private static final Logger LOG = LoggerFactory.getLogger(Ipv6Customizer.class);
+
+ public Ipv6Customizer(final FutureJVppCore vppApi) {
+ super(vppApi);
+ }
+
+ @Override
+ public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<Ipv6> id,
+ @Nonnull final Ipv6 dataAfter, @Nonnull final WriteContext writeContext) {
+ LOG.warn("Unsupported, ignoring configuration {}", dataAfter);
+ }
+
+ @Override
+ public void updateCurrentAttributes(@Nonnull final InstanceIdentifier<Ipv6> id,
+ @Nonnull final Ipv6 dataBefore, @Nonnull final Ipv6 dataAfter,
+ @Nonnull final WriteContext writeContext) {
+ LOG.warn("Unsupported, ignoring configuration {}", dataAfter);
+ }
+
+ @Override
+ public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<Ipv6> id,
+ @Nonnull final Ipv6 dataBefore, @Nonnull final WriteContext writeContext) {
+ LOG.warn("Unsupported, ignoring configuration delete {}", id);
+ }
+}
diff --git a/l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv6/Ipv6NeighbourCustomizer.java b/l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv6/Ipv6NeighbourCustomizer.java
new file mode 100644
index 000000000..2a9ef03d6
--- /dev/null
+++ b/l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv6/Ipv6NeighbourCustomizer.java
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2017 Cisco 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.l3.write.ipv6;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+
+import io.fd.hc2vpp.common.translate.util.AddressTranslator;
+import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
+import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
+import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
+import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.honeycomb.translate.MappingContext;
+import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
+import io.fd.honeycomb.translate.write.WriteContext;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import io.fd.vpp.jvpp.core.dto.IpNeighborAddDel;
+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.interfaces.rev140508.interfaces.Interface;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv6.Neighbor;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv6.NeighborKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class Ipv6NeighbourCustomizer extends FutureJVppCustomizer
+ implements ListWriterCustomizer<Neighbor, NeighborKey>, ByteDataTranslator, AddressTranslator,
+ JvppReplyConsumer {
+
+ private static final Logger LOG = LoggerFactory.getLogger(Ipv6NeighbourCustomizer.class);
+ final NamingContext interfaceContext;
+
+ public Ipv6NeighbourCustomizer(final FutureJVppCore futureJVppCore, final NamingContext interfaceContext) {
+ super(futureJVppCore);
+ this.interfaceContext = interfaceContext;
+ }
+
+ @Override
+ public void writeCurrentAttributes(@Nonnull InstanceIdentifier<Neighbor> id, @Nonnull Neighbor dataAfter,
+ @Nonnull WriteContext writeContext)
+ throws WriteFailedException {
+
+ checkNotNull(dataAfter, "Cannot write null neighbour");
+ checkArgument(id.firstKeyOf(Interface.class) != null, "No parent interface key found");
+
+ LOG.debug("Processing request for Neigbour write");
+ String interfaceName = id.firstKeyOf(Interface.class).getName();
+ MappingContext mappingContext = writeContext.getMappingContext();
+
+ checkState(interfaceContext.containsIndex(interfaceName, mappingContext),
+ "Mapping does not contains mapping for provider interface name ".concat(interfaceName));
+
+ LOG.debug("Parent interface index found");
+ addDelNeighbourAndReply(id, true, interfaceContext.getIndex(interfaceName, mappingContext), dataAfter);
+ LOG.debug("Neighbour successfully written");
+ }
+
+ @Override
+ public void updateCurrentAttributes(@Nonnull InstanceIdentifier<Neighbor> id, @Nonnull Neighbor dataBefore,
+ @Nonnull Neighbor dataAfter,
+ @Nonnull WriteContext writeContext) throws WriteFailedException {
+ throw new UnsupportedOperationException("Operation not supported");
+ }
+
+ @Override
+ public void deleteCurrentAttributes(@Nonnull InstanceIdentifier<Neighbor> id, @Nonnull Neighbor dataBefore,
+ @Nonnull WriteContext writeContext)
+ throws WriteFailedException {
+
+ checkNotNull(dataBefore, "Cannot delete null neighbour");
+ checkArgument(id.firstKeyOf(Interface.class) != null, "No parent interface key found");
+
+ LOG.debug("Processing request for Neigbour delete");
+ String interfaceName = id.firstKeyOf(Interface.class).getName();
+ MappingContext mappingContext = writeContext.getMappingContext();
+
+ checkState(interfaceContext.containsIndex(interfaceName, mappingContext),
+ "Mapping does not contains mapping for provider interface name %s", interfaceName);
+
+ LOG.debug("Parent interface[{}] index found", interfaceName);
+
+ addDelNeighbourAndReply(id, false, interfaceContext.getIndex(interfaceName, mappingContext), dataBefore);
+ LOG.debug("Neighbour {} successfully deleted", id);
+ }
+
+ private void addDelNeighbourAndReply(InstanceIdentifier<Neighbor> id, boolean add, int parentInterfaceIndex,
+ Neighbor data) throws WriteFailedException {
+
+ IpNeighborAddDel request = new IpNeighborAddDel();
+
+ request.isAdd = booleanToByte(add);
+ request.isIpv6 = 1;
+ request.isStatic = 1;
+ request.dstAddress = ipv6AddressNoZoneToArray(data.getIp());
+ request.macAddress = parseMac(data.getLinkLayerAddress().getValue());
+ request.swIfIndex = parentInterfaceIndex;
+ getReplyForWrite(getFutureJVpp().ipNeighborAddDel(request).toCompletableFuture(), id);
+ }
+}
diff --git a/l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv6/nd/NdProxyCustomizer.java b/l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv6/nd/NdProxyCustomizer.java
new file mode 100644
index 000000000..5a57d96d4
--- /dev/null
+++ b/l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv6/nd/NdProxyCustomizer.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2017 Cisco 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.l3.write.ipv6.nd;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import io.fd.hc2vpp.common.translate.util.AddressTranslator;
+import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
+import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
+import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
+import io.fd.honeycomb.translate.write.WriteContext;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import io.fd.vpp.jvpp.core.dto.Ip6NdProxyAddDel;
+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.inet.types.rev130715.Ipv6AddressNoZone;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nd.proxy.rev170315.interfaces._interface.ipv6.nd.proxies.NdProxy;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nd.proxy.rev170315.interfaces._interface.ipv6.nd.proxies.NdProxyKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public final class NdProxyCustomizer extends FutureJVppCustomizer
+ implements ListWriterCustomizer<NdProxy, NdProxyKey>, AddressTranslator, JvppReplyConsumer {
+
+ private static final Logger LOG = LoggerFactory.getLogger(NdProxyCustomizer.class);
+ private final NamingContext interfaceContext;
+
+ public NdProxyCustomizer(@Nonnull final FutureJVppCore futureJVppCore,
+ @Nonnull final NamingContext interfaceContext) {
+ super(futureJVppCore);
+ this.interfaceContext = checkNotNull(interfaceContext, "Interface context cannot be null");
+ }
+
+ @Override
+ public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<NdProxy> id, @Nonnull final NdProxy dataAfter,
+ @Nonnull final WriteContext writeContext) throws WriteFailedException {
+ final String interfaceName = id.firstKeyOf(Interface.class).getName();
+ final int swIfIndex = interfaceContext.getIndex(interfaceName, writeContext.getMappingContext());
+ addDelNdProxy(id, swIfIndex, dataAfter.getAddress(), true);
+ LOG.debug("ND proxy was successfully added for interface {}(id={}): {}", interfaceName, swIfIndex, dataAfter);
+ }
+
+ @Override
+ public void updateCurrentAttributes(@Nonnull final InstanceIdentifier<NdProxy> id,
+ @Nonnull final NdProxy dataBefore, @Nonnull final NdProxy dataAfter,
+ @Nonnull final WriteContext writeContext) throws WriteFailedException {
+ throw new WriteFailedException.UpdateFailedException(id, dataBefore, dataAfter,
+ new UnsupportedOperationException("NdProxy update is not supported."));
+ }
+
+ @Override
+ public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<NdProxy> id,
+ @Nonnull final NdProxy dataBefore,
+ @Nonnull final WriteContext writeContext) throws WriteFailedException {
+ final String interfaceName = id.firstKeyOf(Interface.class).getName();
+ final int swIfIndex = interfaceContext.getIndex(interfaceName, writeContext.getMappingContext());
+ addDelNdProxy(id, swIfIndex, dataBefore.getAddress(), false);
+ LOG.debug("ND proxy was successfully removed from interface {}(id={}): {}", interfaceName, swIfIndex,
+ dataBefore);
+ }
+
+ private void addDelNdProxy(final InstanceIdentifier<NdProxy> id, final int swIfIndex,
+ final Ipv6AddressNoZone address, final boolean add)
+ throws WriteFailedException {
+
+ final byte[] addressBytes = ipv6AddressNoZoneToArray(address);
+
+ final Ip6NdProxyAddDel request = new Ip6NdProxyAddDel();
+ request.swIfIndex = swIfIndex;
+ request.address = addressBytes;
+ request.isDel = booleanToByte(!add);
+
+ getReplyForWrite(getFutureJVpp().ip6NdProxyAddDel(request).toCompletableFuture(), id);
+ }
+
+
+}
diff --git a/l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv6/subinterface/SubInterfaceIpv6AddressCustomizer.java b/l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv6/subinterface/SubInterfaceIpv6AddressCustomizer.java
new file mode 100644
index 000000000..5562eeeb6
--- /dev/null
+++ b/l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv6/subinterface/SubInterfaceIpv6AddressCustomizer.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2017 Cisco 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.l3.write.ipv6.subinterface;
+
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
+import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.hc2vpp.l3.utils.ip.write.IpWriter;
+import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
+import io.fd.honeycomb.translate.write.WriteContext;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.ip6.attributes.ipv6.Address;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.ip6.attributes.ipv6.AddressKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class SubInterfaceIpv6AddressCustomizer extends FutureJVppCustomizer
+ implements ListWriterCustomizer<Address, AddressKey>, IpWriter {
+
+ private final NamingContext interfaceContext;
+
+ public SubInterfaceIpv6AddressCustomizer(@Nonnull final FutureJVppCore futureJVppCore,
+ @Nonnull final NamingContext interfaceContext) {
+ super(futureJVppCore);
+ this.interfaceContext = checkNotNull(interfaceContext, "interface context should not be null");
+ }
+
+ @Override
+ public void writeCurrentAttributes(InstanceIdentifier<Address> id, Address dataAfter, WriteContext writeContext)
+ throws WriteFailedException {
+ setAddress(true, id, dataAfter, writeContext);
+ }
+
+ @Override
+ public void updateCurrentAttributes(InstanceIdentifier<Address> id, Address dataBefore, Address dataAfter,
+ WriteContext writeContext) throws WriteFailedException {
+ throw new WriteFailedException.UpdateFailedException(id, dataBefore, dataAfter,
+ new UnsupportedOperationException("Operation not supported"));
+ }
+
+ @Override
+ public void deleteCurrentAttributes(InstanceIdentifier<Address> id, Address dataBefore, WriteContext writeContext)
+ throws WriteFailedException {
+ setAddress(false, id, dataBefore, writeContext);
+ }
+
+ private void setAddress(boolean add,
+ final InstanceIdentifier<Address> id,
+ final Address address,
+ final WriteContext writeContext) throws WriteFailedException {
+
+ addDelAddress(getFutureJVpp(), add, id,
+ subInterfaceIndex(id, interfaceContext, writeContext.getMappingContext()), address.getIp(),
+ address.getPrefixLength().byteValue());
+ }
+}
diff --git a/l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv6/subinterface/SubInterfaceIpv6NeighbourCustomizer.java b/l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv6/subinterface/SubInterfaceIpv6NeighbourCustomizer.java
new file mode 100644
index 000000000..002e14116
--- /dev/null
+++ b/l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv6/subinterface/SubInterfaceIpv6NeighbourCustomizer.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2017 Cisco 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.l3.write.ipv6.subinterface;
+
+import io.fd.hc2vpp.common.translate.util.AddressTranslator;
+import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
+import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
+import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
+import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.hc2vpp.l3.utils.ip.write.IpWriter;
+import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
+import io.fd.honeycomb.translate.write.WriteContext;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import io.fd.vpp.jvpp.core.dto.IpNeighborAddDel;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.ip6.attributes.ipv6.Neighbor;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.ip6.attributes.ipv6.NeighborKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SubInterfaceIpv6NeighbourCustomizer extends FutureJVppCustomizer
+ implements ListWriterCustomizer<Neighbor, NeighborKey>, ByteDataTranslator, AddressTranslator, IpWriter,
+ JvppReplyConsumer {
+
+ private static final Logger LOG = LoggerFactory.getLogger(SubInterfaceIpv6NeighbourCustomizer.class);
+ private final NamingContext interfaceContext;
+
+ public SubInterfaceIpv6NeighbourCustomizer(final FutureJVppCore futureJVppCore,
+ final NamingContext interfaceContext) {
+ super(futureJVppCore);
+ this.interfaceContext = interfaceContext;
+ }
+
+ @Override
+ public void writeCurrentAttributes(@Nonnull InstanceIdentifier<Neighbor> id, @Nonnull Neighbor data,
+ @Nonnull WriteContext writeContext)
+ throws WriteFailedException {
+
+ LOG.debug("Processing request for Neighbour {} write", id);
+
+ addDelNeighbour(id, () -> {
+ IpNeighborAddDel request = preBindIpv6Request(true);
+
+ request.dstAddress = ipv6AddressNoZoneToArray(data.getIp());
+ request.macAddress = parseMac(data.getLinkLayerAddress().getValue());
+ request.swIfIndex = subInterfaceIndex(id, interfaceContext, writeContext.getMappingContext());
+ // we don't have support for sub-interface routing, so not setting vrf
+
+ return request;
+ }, getFutureJVpp());
+ LOG.debug("Neighbour {} successfully written", id);
+ }
+
+ @Override
+ public void updateCurrentAttributes(@Nonnull InstanceIdentifier<Neighbor> id, @Nonnull Neighbor dataBefore,
+ @Nonnull Neighbor dataAfter,
+ @Nonnull WriteContext writeContext) throws WriteFailedException {
+ throw new UnsupportedOperationException("Operation not supported");
+ }
+
+ @Override
+ public void deleteCurrentAttributes(@Nonnull InstanceIdentifier<Neighbor> id, @Nonnull Neighbor data,
+ @Nonnull WriteContext writeContext)
+ throws WriteFailedException {
+
+ LOG.debug("Processing request for Neighbour {} delete", id);
+
+ addDelNeighbour(id, () -> {
+ IpNeighborAddDel request = preBindIpv6Request(false);
+
+ request.dstAddress = ipv6AddressNoZoneToArray(data.getIp());
+ request.macAddress = parseMac(data.getLinkLayerAddress().getValue());
+ request.swIfIndex = subInterfaceIndex(id, interfaceContext, writeContext.getMappingContext());
+
+ //TODO HONEYCOMB-182 if it is necessary for future use ,make adjustments to be able to set vrfid
+ //request.vrfId
+ return request;
+ }, getFutureJVpp());
+
+ LOG.debug("Neighbour {} successfully deleted", id);
+ }
+
+}