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;
20 import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
21 import io.fd.hc2vpp.common.translate.util.NamingContext;
22 import io.fd.hc2vpp.l3.utils.ip.write.IpWriter;
23 import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
24 import io.fd.honeycomb.translate.write.WriteContext;
25 import io.fd.honeycomb.translate.write.WriteFailedException;
26 import io.fd.jvpp.core.future.FutureJVppCore;
27 import javax.annotation.Nonnull;
28 import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.vlan.rev180319.sub._interface.ip6.attributes.ipv6.Address;
29 import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.vlan.rev180319.sub._interface.ip6.attributes.ipv6.AddressKey;
30 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
32 public class SubInterfaceIpv6AddressCustomizer extends FutureJVppCustomizer
33 implements ListWriterCustomizer<Address, AddressKey>, IpWriter {
35 private final NamingContext interfaceContext;
37 public SubInterfaceIpv6AddressCustomizer(@Nonnull final FutureJVppCore futureJVppCore,
38 @Nonnull final NamingContext interfaceContext) {
39 super(futureJVppCore);
40 this.interfaceContext = interfaceContext;
44 public void writeCurrentAttributes(InstanceIdentifier<Address> id, Address dataAfter, WriteContext writeContext)
45 throws WriteFailedException {
46 setAddress(true, id, dataAfter, writeContext);
50 public void deleteCurrentAttributes(InstanceIdentifier<Address> id, Address dataBefore, WriteContext writeContext)
51 throws WriteFailedException {
52 setAddress(false, id, dataBefore, writeContext);
55 private void setAddress(boolean add,
56 final InstanceIdentifier<Address> id,
57 final Address address,
58 final WriteContext writeContext) throws WriteFailedException {
60 addDelAddress(getFutureJVpp(), add, id,
61 subInterfaceIndex(id, interfaceContext, writeContext.getMappingContext()), address.getIp(),
62 address.getPrefixLength().byteValue());