summaryrefslogtreecommitdiffstats
path: root/v3po/v3po2vpp/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'v3po/v3po2vpp/src/main/java')
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/Ipv6StateReaderFactory.java15
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/Ipv6WriterFactory.java8
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/ip/v6/nd/NdProxyCustomizer.java94
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/ip/v6/nd/NdProxyCustomizer.java140
4 files changed, 257 insertions, 0 deletions
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/Ipv6StateReaderFactory.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/Ipv6StateReaderFactory.java
index 628cd14f3..b1533dfae 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/Ipv6StateReaderFactory.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/Ipv6StateReaderFactory.java
@@ -25,6 +25,7 @@ import io.fd.hc2vpp.common.translate.util.NamingContext;
import io.fd.hc2vpp.v3po.interfacesstate.ip.v6.Ipv6AddressCustomizer;
import io.fd.hc2vpp.v3po.interfacesstate.ip.v6.Ipv6Customizer;
import io.fd.hc2vpp.v3po.interfacesstate.ip.v6.Ipv6NeighbourCustomizer;
+import io.fd.hc2vpp.v3po.interfacesstate.ip.v6.nd.NdProxyCustomizer;
import io.fd.honeycomb.translate.impl.read.GenericInitListReader;
import io.fd.honeycomb.translate.impl.read.GenericListReader;
import io.fd.honeycomb.translate.impl.read.GenericReader;
@@ -36,6 +37,11 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev14061
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces.state._interface.Ipv6;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces.state._interface.ipv6.Address;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces.state._interface.ipv6.Neighbor;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nd.proxy.rev170315.NdProxyIp6StateAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nd.proxy.rev170315.NdProxyIp6StateAugmentationBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nd.proxy.rev170315.interfaces.state._interface.ipv6.NdProxies;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nd.proxy.rev170315.interfaces.state._interface.ipv6.NdProxiesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nd.proxy.rev170315.interfaces.state._interface.ipv6.nd.proxies.NdProxy;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
public class Ipv6StateReaderFactory implements ReaderFactory {
@@ -60,5 +66,14 @@ public class Ipv6StateReaderFactory implements ReaderFactory {
// Ipv6 Neighbor
final InstanceIdentifier<Neighbor> neighborId = ipv6Id.child(Neighbor.class);
registry.add(new GenericListReader<>(neighborId, new Ipv6NeighbourCustomizer(jvpp, ifcNamingCtx)));
+ // NdProxyIp6StateAugmentation (Structural)
+ final InstanceIdentifier<NdProxyIp6StateAugmentation> ndAugId = ipv6Id.augmentation(NdProxyIp6StateAugmentation.class);
+ registry.addStructuralReader(ndAugId, NdProxyIp6StateAugmentationBuilder.class);
+ // NdProxies (Structural)
+ final InstanceIdentifier<NdProxies> ndProxiesId = ndAugId.child(NdProxies.class);
+ registry.addStructuralReader(ndProxiesId, NdProxiesBuilder.class);
+ // ND Proxy
+ final InstanceIdentifier<NdProxy> ndProxyId = ndProxiesId.child(NdProxy.class);
+ registry.addAfter(new GenericInitListReader<>(ndProxyId, new NdProxyCustomizer(jvpp, ifcNamingCtx)), ipv6AddrId);
}
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/Ipv6WriterFactory.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/Ipv6WriterFactory.java
index ce63eb1af..9fbd6b9ba 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/Ipv6WriterFactory.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/Ipv6WriterFactory.java
@@ -24,6 +24,7 @@ import io.fd.hc2vpp.common.translate.util.NamingContext;
import io.fd.hc2vpp.v3po.interfaces.ip.v6.Ipv6AddressCustomizer;
import io.fd.hc2vpp.v3po.interfaces.ip.v6.Ipv6Customizer;
import io.fd.hc2vpp.v3po.interfaces.ip.v6.Ipv6NeighbourCustomizer;
+import io.fd.hc2vpp.v3po.interfaces.ip.v6.nd.NdProxyCustomizer;
import io.fd.honeycomb.translate.impl.write.GenericListWriter;
import io.fd.honeycomb.translate.impl.write.GenericWriter;
import io.fd.honeycomb.translate.write.WriterFactory;
@@ -34,6 +35,9 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev14061
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.Ipv6;
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.Neighbor;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nd.proxy.rev170315.NdProxyIp6Augmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nd.proxy.rev170315.interfaces._interface.ipv6.NdProxies;
+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.yangtools.yang.binding.InstanceIdentifier;
/**
@@ -64,5 +68,9 @@ public class Ipv6WriterFactory implements WriterFactory {
registry.addAfter(new GenericListWriter<>(ipv6Id.child(Neighbor.class),
new Ipv6NeighbourCustomizer(jvpp, ifcNamingContext)), ipv6AddressId);
+ // ND Proxy
+ final InstanceIdentifier<NdProxy> ndProxyId =
+ ipv6Id.augmentation(NdProxyIp6Augmentation.class).child(NdProxies.class).child(NdProxy.class);
+ registry.addAfter(new GenericListWriter<>(ndProxyId, new NdProxyCustomizer(jvpp, ifcNamingContext)), ipv6Id);
}
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/ip/v6/nd/NdProxyCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/ip/v6/nd/NdProxyCustomizer.java
new file mode 100644
index 000000000..ed3d82ca9
--- /dev/null
+++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/ip/v6/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.v3po.interfaces.ip.v6.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/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/ip/v6/nd/NdProxyCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/ip/v6/nd/NdProxyCustomizer.java
new file mode 100644
index 000000000..7ffde1dd4
--- /dev/null
+++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/ip/v6/nd/NdProxyCustomizer.java
@@ -0,0 +1,140 @@
+/*
+ * 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.v3po.interfacesstate.ip.v6.nd;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor.NO_PARAMS;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Optional;
+import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
+import io.fd.hc2vpp.common.translate.util.Ipv6Translator;
+import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
+import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.hc2vpp.v3po.interfacesstate.InterfaceCustomizer;
+import io.fd.honeycomb.translate.read.ReadContext;
+import io.fd.honeycomb.translate.read.ReadFailedException;
+import io.fd.honeycomb.translate.spi.read.Initialized;
+import io.fd.honeycomb.translate.spi.read.InitializingListReaderCustomizer;
+import io.fd.honeycomb.translate.util.RWUtils;
+import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager;
+import io.fd.vpp.jvpp.core.dto.Ip6NdProxyDetailsReplyDump;
+import io.fd.vpp.jvpp.core.dto.Ip6NdProxyDump;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+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.state.Interface;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.Interface1;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.Ipv6;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nd.proxy.rev170315.NdProxyIp6Augmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nd.proxy.rev170315.interfaces.state._interface.ipv6.NdProxiesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nd.proxy.rev170315.interfaces.state._interface.ipv6.nd.proxies.NdProxy;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nd.proxy.rev170315.interfaces.state._interface.ipv6.nd.proxies.NdProxyBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nd.proxy.rev170315.interfaces.state._interface.ipv6.nd.proxies.NdProxyKey;
+import org.opendaylight.yangtools.concepts.Builder;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public final class NdProxyCustomizer extends FutureJVppCustomizer
+ implements InitializingListReaderCustomizer<NdProxy, NdProxyKey, NdProxyBuilder>, JvppReplyConsumer,
+ Ipv6Translator {
+
+ private static final Logger LOG = LoggerFactory.getLogger(NdProxyCustomizer.class);
+ private final NamingContext interfaceContext;
+ private final DumpCacheManager<Ip6NdProxyDetailsReplyDump, Void> dumpManager;
+
+ public NdProxyCustomizer(@Nonnull final FutureJVppCore futureJVppCore,
+ @Nonnull final NamingContext interfaceContext) {
+ super(futureJVppCore);
+ this.interfaceContext = checkNotNull(interfaceContext, "interfaceContext should not be null");
+ dumpManager = new DumpCacheManager.DumpCacheManagerBuilder<Ip6NdProxyDetailsReplyDump, Void>()
+ .withExecutor((id, param) -> getReplyForRead(
+ getFutureJVpp().ip6NdProxyDump(new Ip6NdProxyDump()).toCompletableFuture(), id))
+ .acceptOnly(Ip6NdProxyDetailsReplyDump.class)
+ .build();
+ }
+
+ @Nonnull
+ @Override
+ public List<NdProxyKey> getAllIds(@Nonnull final InstanceIdentifier<NdProxy> id,
+ @Nonnull final ReadContext context) throws ReadFailedException {
+ final String interfaceName = id.firstKeyOf(Interface.class).getName();
+ final int swIfIndex = interfaceContext.getIndex(interfaceName, context.getMappingContext());
+ LOG.debug("Reading NDProxies for interface {}(id={})", interfaceName, swIfIndex);
+ final Optional<Ip6NdProxyDetailsReplyDump> dump =
+ dumpManager.getDump(id, context.getModificationCache(), NO_PARAMS);
+
+ if (!dump.isPresent() || dump.get().ip6NdProxyDetails.isEmpty()) {
+ return Collections.emptyList();
+ }
+
+ return dump.get().ip6NdProxyDetails.stream()
+ .filter(detail -> detail.swIfIndex == swIfIndex)
+ .map(detail -> new NdProxyKey(arrayToIpv6AddressNoZone(detail.address)))
+ .collect(Collectors.toList());
+ }
+
+ @Override
+ public void merge(@Nonnull final Builder<? extends DataObject> builder, @Nonnull final List<NdProxy> list) {
+ ((NdProxiesBuilder)builder).setNdProxy(list);
+ }
+
+ @Nonnull
+ @Override
+ public NdProxyBuilder getBuilder(@Nonnull final InstanceIdentifier<NdProxy> instanceIdentifier) {
+ return new NdProxyBuilder();
+ }
+
+ @Override
+ public void readCurrentAttributes(@Nonnull final InstanceIdentifier<NdProxy> id,
+ @Nonnull final NdProxyBuilder builder,
+ @Nonnull final ReadContext context)
+ throws ReadFailedException {
+ // address is the only leaf and list key, so jvpp call is not needed:
+ builder.setAddress(id.firstKeyOf(NdProxy.class).getAddress());
+ }
+
+ @Nonnull
+ @Override
+ public Initialized<? extends DataObject> init(@Nonnull final InstanceIdentifier<NdProxy> id,
+ @Nonnull final NdProxy ndProxy,
+ @Nonnull final ReadContext readContext) {
+ return Initialized.create(getCfgId(id),
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nd.proxy.rev170315.interfaces._interface.ipv6.nd.proxies.NdProxyBuilder()
+ .setAddress(ndProxy.getAddress())
+ .build());
+ }
+
+ @VisibleForTesting
+ protected static InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nd.proxy.rev170315.interfaces._interface.ipv6.nd.proxies.NdProxy> getCfgId(
+ final InstanceIdentifier<NdProxy> id) {
+ final Ipv6AddressNoZone address = id.firstKeyOf(NdProxy.class).getAddress();
+ return InterfaceCustomizer.getCfgId(RWUtils.cutId(id, Interface.class))
+ .augmentation(Interface1.class).child(Ipv6.class).augmentation(NdProxyIp6Augmentation.class)
+ .child(
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nd.proxy.rev170315.interfaces._interface.ipv6.NdProxies.class)
+ .child(
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nd.proxy.rev170315.interfaces._interface.ipv6.nd.proxies.NdProxy.class,
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nd.proxy.rev170315.interfaces._interface.ipv6.nd.proxies.NdProxyKey(
+ address));
+ }
+}