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.vpp.classifier.factory.write;
19 import static io.fd.hc2vpp.vpp.classifier.factory.write.VppClassifierHoneycombWriterFactory.CLASSIFY_SESSION_ID;
20 import static io.fd.hc2vpp.vpp.classifier.factory.write.VppClassifierHoneycombWriterFactory.CLASSIFY_TABLE_ID;
22 import com.google.common.collect.Sets;
23 import com.google.inject.Inject;
24 import com.google.inject.name.Named;
25 import io.fd.hc2vpp.common.translate.util.NamingContext;
26 import io.fd.hc2vpp.vpp.classifier.context.VppClassifierContextManager;
27 import io.fd.hc2vpp.vpp.classifier.write.acl.ingress.AclCustomizer;
28 import io.fd.honeycomb.translate.impl.write.GenericWriter;
29 import io.fd.honeycomb.translate.write.WriterFactory;
30 import io.fd.honeycomb.translate.write.registry.ModifiableWriterRegistryBuilder;
31 import io.fd.vpp.jvpp.core.future.FutureJVppCore;
32 import javax.annotation.Nonnull;
33 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces;
34 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp._interface.acl.rev170315.VppInterfaceAclAugmentation;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.acl.rev170503.acl.base.attributes.Ip4Acl;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.acl.rev170503.acl.base.attributes.Ip6Acl;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.acl.rev170503.acl.base.attributes.L2Acl;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.acl.rev170503.vpp.acl.attributes.Acl;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.acl.rev170503.vpp.acl.attributes.acl.Ingress;
41 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
43 public class InterfaceAclWriterFactory implements WriterFactory {
45 private static final InstanceIdentifier<Interface> IFC_ID =
46 InstanceIdentifier.create(Interfaces.class).child(Interface.class);
47 private static final InstanceIdentifier<VppInterfaceAclAugmentation> VPP_IFC_ACL_ID =
48 IFC_ID.augmentation(VppInterfaceAclAugmentation.class);
49 static final InstanceIdentifier<Acl> ACL_ID = VPP_IFC_ACL_ID.child(Acl.class);
50 private static final InstanceIdentifier<Ingress> INGRESS_ACL_ID = ACL_ID.child(Ingress.class);
53 private FutureJVppCore jvpp;
56 @Named("interface-context")
57 private NamingContext ifcNamingContext;
60 @Named("classify-table-context")
61 private VppClassifierContextManager classifyTableContext;
65 public void init(@Nonnull ModifiableWriterRegistryBuilder registry) {
66 // Ingress (execute after classify table and session writers)
67 // also handles L2Acl, Ip4Acl and Ip6Acl:
68 final InstanceIdentifier<Ingress> ingressId = InstanceIdentifier.create(Ingress.class);
71 Sets.newHashSet(ingressId.child(L2Acl.class), ingressId.child(Ip4Acl.class),
72 ingressId.child(Ip6Acl.class)),
73 new GenericWriter<>(INGRESS_ACL_ID,
74 new AclCustomizer(jvpp, ifcNamingContext, classifyTableContext)),
75 Sets.newHashSet(CLASSIFY_TABLE_ID, CLASSIFY_SESSION_ID));