2 * Copyright (c) 2017 Cisco and/or its affiliates.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package io.fd.hc2vpp.l3.write.ipv6.subinterface;
19 import io.fd.hc2vpp.common.translate.util.AddressTranslator;
20 import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
21 import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
22 import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
23 import io.fd.hc2vpp.common.translate.util.NamingContext;
24 import io.fd.hc2vpp.l3.utils.ip.write.IpWriter;
25 import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
26 import io.fd.honeycomb.translate.write.WriteContext;
27 import io.fd.honeycomb.translate.write.WriteFailedException;
28 import io.fd.vpp.jvpp.core.dto.IpNeighborAddDel;
29 import io.fd.vpp.jvpp.core.future.FutureJVppCore;
30 import javax.annotation.Nonnull;
31 import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.vlan.rev180319.sub._interface.ip6.attributes.ipv6.Neighbor;
32 import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.vlan.rev180319.sub._interface.ip6.attributes.ipv6.NeighborKey;
33 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
34 import org.slf4j.Logger;
35 import org.slf4j.LoggerFactory;
37 public class SubInterfaceIpv6NeighbourCustomizer extends FutureJVppCustomizer
38 implements ListWriterCustomizer<Neighbor, NeighborKey>, ByteDataTranslator, AddressTranslator, IpWriter,
41 private static final Logger LOG = LoggerFactory.getLogger(SubInterfaceIpv6NeighbourCustomizer.class);
42 private final NamingContext interfaceContext;
44 public SubInterfaceIpv6NeighbourCustomizer(final FutureJVppCore futureJVppCore,
45 final NamingContext interfaceContext) {
46 super(futureJVppCore);
47 this.interfaceContext = interfaceContext;
51 public void writeCurrentAttributes(@Nonnull InstanceIdentifier<Neighbor> id, @Nonnull Neighbor data,
52 @Nonnull WriteContext writeContext)
53 throws WriteFailedException {
55 LOG.debug("Processing request for Neighbour {} write", id);
57 addDelNeighbour(id, () -> {
58 IpNeighborAddDel request = preBindRequest(true);
59 request.neighbor.macAddress = parseMacAddress(data.getLinkLayerAddress().getValue());
60 request.neighbor.ipAddress = ipv6AddressToAddress(data.getIp());
61 request.neighbor.swIfIndex = subInterfaceIndex(id, interfaceContext, writeContext.getMappingContext());
62 // we don't have support for sub-interface routing, so not setting vrf
66 LOG.debug("Neighbour {} successfully written", id);
70 public void deleteCurrentAttributes(@Nonnull InstanceIdentifier<Neighbor> id, @Nonnull Neighbor data,
71 @Nonnull WriteContext writeContext)
72 throws WriteFailedException {
74 LOG.debug("Processing request for Neighbour {} delete", id);
76 addDelNeighbour(id, () -> {
77 IpNeighborAddDel request = preBindRequest(false);
78 request.neighbor.macAddress = parseMacAddress(data.getLinkLayerAddress().getValue());
79 request.neighbor.ipAddress = ipv6AddressToAddress(data.getIp());
80 request.neighbor.swIfIndex = subInterfaceIndex(id, interfaceContext, writeContext.getMappingContext());
82 //TODO HONEYCOMB-182 if it is necessary for future use ,make adjustments to be able to set vrfid
87 LOG.debug("Neighbour {} successfully deleted", id);