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 com.google.common.collect.Sets;
20 import com.google.inject.Inject;
21 import com.google.inject.name.Named;
22 import io.fd.hc2vpp.common.translate.util.NamingContext;
23 import io.fd.hc2vpp.v3po.factory.InterfacesWriterFactory;
24 import io.fd.hc2vpp.vpp.classifier.context.VppClassifierContextManager;
25 import io.fd.hc2vpp.vpp.classifier.write.acl.ingress.AclValidator;
26 import io.fd.hc2vpp.vpp.classifier.write.acl.ingress.SubInterfaceAclCustomizer;
27 import io.fd.honeycomb.translate.impl.write.GenericWriter;
28 import io.fd.honeycomb.translate.write.WriterFactory;
29 import io.fd.honeycomb.translate.write.registry.ModifiableWriterRegistryBuilder;
30 import io.fd.jvpp.core.future.FutureJVppCore;
31 import javax.annotation.Nonnull;
32 import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.classifier.acl.rev170503.acl.base.attributes.Ip4Acl;
33 import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.classifier.acl.rev170503.acl.base.attributes.Ip6Acl;
34 import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.classifier.acl.rev170503.acl.base.attributes.L2Acl;
35 import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.classifier.acl.rev170503.vpp.acl.attributes.Acl;
36 import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.classifier.acl.rev170503.vpp.acl.attributes.acl.Ingress;
37 import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.subinterface.acl.rev170315.VppSubinterfaceAclAugmentation;
38 import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.vlan.rev180319.SubinterfaceAugmentation;
39 import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.vlan.rev180319.interfaces._interface.SubInterfaces;
40 import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.vlan.rev180319.interfaces._interface.sub.interfaces.SubInterface;
41 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
43 public class SubInterfaceAclWriterFactory implements WriterFactory {
45 public static final InstanceIdentifier<SubinterfaceAugmentation> SUB_IFC_AUG_ID =
46 InterfacesWriterFactory.IFC_ID.augmentation(SubinterfaceAugmentation.class);
47 public static final InstanceIdentifier<SubInterface> SUB_IFC_ID =
48 SUB_IFC_AUG_ID.child(SubInterfaces.class).child(SubInterface.class);
49 public static final InstanceIdentifier<VppSubinterfaceAclAugmentation> SUB_IF_ACL_AUG_ID =
50 SUB_IFC_ID.augmentation(VppSubinterfaceAclAugmentation.class);
52 public static final InstanceIdentifier<Acl> SUBIF_ACL_ID = SUB_IF_ACL_AUG_ID.child(Acl.class);
53 public static final InstanceIdentifier<Ingress> SUBIF_INGRESS_ACL_ID = SUBIF_ACL_ID.child(Ingress.class);
56 private FutureJVppCore jvpp;
59 @Named("interface-context")
60 private NamingContext ifcNamingContext;
63 @Named("classify-table-context")
64 private VppClassifierContextManager classifyTableContext;
67 public void init(@Nonnull ModifiableWriterRegistryBuilder registry) {
68 // Ingress (execute after classify table and session writers)
69 // also handles L2Acl, Ip4Acl and Ip6Acl:
70 final InstanceIdentifier<Ingress> aclId = InstanceIdentifier.create(Ingress.class);
73 Sets.newHashSet(aclId.child(L2Acl.class), aclId.child(Ip4Acl.class), aclId.child(Ip6Acl.class)),
74 new GenericWriter<>(SUBIF_INGRESS_ACL_ID,
75 new SubInterfaceAclCustomizer(jvpp, ifcNamingContext, classifyTableContext),
76 new AclValidator(ifcNamingContext, classifyTableContext)),
77 Sets.newHashSet(VppClassifierHoneycombWriterFactory.CLASSIFY_TABLE_ID,
78 VppClassifierHoneycombWriterFactory.CLASSIFY_SESSION_ID));