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.read;
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.vpp.classifier.context.VppClassifierContextManager;
24 import io.fd.hc2vpp.vpp.classifier.read.acl.SubInterfaceAclCustomizer;
25 import io.fd.honeycomb.translate.impl.read.GenericInitReader;
26 import io.fd.honeycomb.translate.read.ReaderFactory;
27 import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder;
28 import io.fd.vpp.jvpp.core.future.FutureJVppCore;
29 import javax.annotation.Nonnull;
30 import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.classifier.acl.rev170503.acl.base.attributes.Ip4Acl;
31 import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.classifier.acl.rev170503.acl.base.attributes.Ip6Acl;
32 import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.classifier.acl.rev170503.acl.base.attributes.L2Acl;
33 import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.classifier.acl.rev170503.vpp.acl.attributes.Acl;
34 import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.classifier.acl.rev170503.vpp.acl.attributes.AclBuilder;
35 import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.classifier.acl.rev170503.vpp.acl.attributes.acl.Ingress;
36 import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.subinterface.acl.rev170315.VppSubinterfaceAclStateAugmentation;
37 import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.subinterface.acl.rev170315.VppSubinterfaceAclStateAugmentationBuilder;
38 import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.vlan.rev180319.SubinterfaceStateAugmentation;
39 import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.vlan.rev180319.interfaces.state._interface.SubInterfaces;
40 import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.vlan.rev180319.interfaces.state._interface.sub.interfaces.SubInterface;
41 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfacesState;
42 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
43 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
45 public class SubInterfaceAclReaderFactory implements ReaderFactory {
47 static final InstanceIdentifier<InterfacesState> IFC_STATE_ID =
48 InstanceIdentifier.create(InterfacesState.class);
49 static final InstanceIdentifier<Interface> IFC_ID = IFC_STATE_ID.child(Interface.class);
51 private static final InstanceIdentifier<VppSubinterfaceAclStateAugmentation> SUB_IFC_AUG_ID =
52 IFC_ID.augmentation(SubinterfaceStateAugmentation.class)
53 .child(SubInterfaces.class)
54 .child(SubInterface.class)
55 .augmentation(VppSubinterfaceAclStateAugmentation.class);
58 private FutureJVppCore jvpp;
61 @Named("interface-context")
62 private NamingContext ifcNamingContext;
65 @Named("classify-table-context")
66 private VppClassifierContextManager classifyTableContext;
69 public void init(@Nonnull ModifiableReaderRegistryBuilder registry) {
70 // Aug readed(Structural)
71 registry.addStructuralReader(SUB_IFC_AUG_ID, VppSubinterfaceAclStateAugmentationBuilder.class);
73 final InstanceIdentifier<Acl> aclIid = SUB_IFC_AUG_ID.child(Acl.class);
74 registry.addStructuralReader(aclIid, AclBuilder.class);
76 final InstanceIdentifier<Ingress> ingressIdRelative = InstanceIdentifier.create(Ingress.class);
78 Sets.newHashSet(ingressIdRelative.child(L2Acl.class), ingressIdRelative.child(Ip4Acl.class),
79 ingressIdRelative.child(Ip6Acl.class)),
80 new GenericInitReader<>(aclIid.child(Ingress.class),
81 new SubInterfaceAclCustomizer(jvpp, ifcNamingContext, classifyTableContext)));