2 * Copyright (c) 2017 Hewlett Packard Enterprise, Co. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.netvirt.aclservice.utils;
11 import com.google.common.base.Optional;
12 import java.math.BigInteger;
13 import java.util.List;
16 import javax.inject.Inject;
17 import javax.inject.Singleton;
19 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
20 import org.opendaylight.genius.mdsalutil.MatchInfoBase;
21 import org.opendaylight.netvirt.aclservice.api.AclServiceManager;
22 import org.opendaylight.netvirt.aclservice.api.utils.AclInterface;
23 import org.opendaylight.netvirt.aclservice.api.utils.IAclServiceUtil;
24 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.Matches;
25 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.InterfaceAcl;
29 public class AclServiceUtilFacade implements IAclServiceUtil {
30 private final AclServiceManager aclServiceManager;
31 private final DataBroker broker;
34 public AclServiceUtilFacade(DataBroker broker, AclServiceManager aclServiceManager) {
36 this.aclServiceManager = aclServiceManager;
40 public Map<String, List<MatchInfoBase>> programIpFlow(Matches matches) {
41 return AclServiceOFFlowBuilder.programIpFlow(matches);
45 public void updateBoundServicesFlow(String interfaceName, Long vpnId) {
46 Optional<Interface> intfc = AclServiceUtils.getInterface(broker, interfaceName);
47 InterfaceAcl aclInPort = intfc.get().getAugmentation(InterfaceAcl.class);
48 if (aclInPort != null && aclInPort.isPortSecurityEnabled()) {
49 aclServiceManager.bindAclTableForVpn(AclServiceUtils.buildAclInterfaceState(interfaceName, aclInPort),
55 public void updateRemoteAclFilterTable(String interfaceName, Long vpnId, BigInteger dpnId, int addOrDelete) {
56 Optional<Interface> intfc = AclServiceUtils.getInterface(broker, interfaceName);
57 InterfaceAcl aclInPort = intfc.get().getAugmentation(InterfaceAcl.class);
58 if (aclInPort != null && aclInPort.isPortSecurityEnabled()) {
59 AclInterface aclInterface = AclServiceUtils.buildAclInterfaceState(interfaceName, aclInPort);
60 aclInterface.setDpId(dpnId);
61 aclServiceManager.updateRemoteAclFilterTable(aclInterface, addOrDelete, vpnId);