use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs in project netvirt by opendaylight.
the class AclServiceUtils method addAclPortsLookup.
public List<ListenableFuture<Void>> addAclPortsLookup(AclInterface port, List<Uuid> aclList, List<AllowedAddressPairs> allowedAddresses) {
String portId = port.getInterfaceId();
LOG.trace("Adding AclPortsLookup for port={}, acls={}, AAPs={}", portId, aclList, allowedAddresses);
if (aclList == null || allowedAddresses == null || allowedAddresses.isEmpty()) {
LOG.warn("aclList or allowedAddresses is null. port={}, acls={}, AAPs={}", portId, aclList, allowedAddresses);
return Collections.emptyList();
}
List<ListenableFuture<Void>> futures = new ArrayList<>();
for (Uuid aclId : aclList) {
String aclName = aclId.getValue();
synchronized (aclName.intern()) {
futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
for (AllowedAddressPairs aap : allowedAddresses) {
PortIds portIdObj = new PortIdsBuilder().setKey(new PortIdsKey(portId)).setPortId(portId).build();
InstanceIdentifier<PortIds> path = AclServiceUtils.getPortIdsPathInAclPortsLookup(aclName, aap.getIpAddress(), portId);
tx.put(LogicalDatastoreType.OPERATIONAL, path, portIdObj, WriteTransaction.CREATE_MISSING_PARENTS);
}
}));
}
}
return futures;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs in project netvirt by opendaylight.
the class AclServiceUtils method buildIpAndSrcServiceMatch.
public static List<? extends MatchInfoBase> buildIpAndSrcServiceMatch(Integer aclTag, AllowedAddressPairs aap) {
List<MatchInfoBase> flowMatches = new ArrayList<>();
flowMatches.add(buildRemoteAclTagMetadataMatch(aclTag));
if (aap.getIpAddress().getIpAddress() != null) {
if (aap.getIpAddress().getIpAddress().getIpv4Address() != null) {
MatchEthernetType ipv4EthMatch = new MatchEthernetType(NwConstants.ETHTYPE_IPV4);
flowMatches.add(ipv4EthMatch);
MatchIpv4Source srcMatch = new MatchIpv4Source(new Ipv4Prefix(aap.getIpAddress().getIpAddress().getIpv4Address().getValue() + "/32"));
flowMatches.add(srcMatch);
} else if (aap.getIpAddress().getIpAddress().getIpv6Address() != null) {
MatchEthernetType ipv6EthMatch = new MatchEthernetType(NwConstants.ETHTYPE_IPV6);
flowMatches.add(ipv6EthMatch);
MatchIpv6Source srcMatch = new MatchIpv6Source(new Ipv6Prefix(aap.getIpAddress().getIpAddress().getIpv6Address().getValue() + "/128"));
flowMatches.add(srcMatch);
}
} else if (aap.getIpAddress().getIpPrefix() != null) {
if (aap.getIpAddress().getIpPrefix().getIpv4Prefix() != null) {
MatchEthernetType ipv4EthMatch = new MatchEthernetType(NwConstants.ETHTYPE_IPV4);
flowMatches.add(ipv4EthMatch);
MatchIpv4Source srcMatch = new MatchIpv4Source(aap.getIpAddress().getIpPrefix().getIpv4Prefix());
flowMatches.add(srcMatch);
} else if (aap.getIpAddress().getIpPrefix().getIpv6Prefix() != null) {
MatchEthernetType ipv6EthMatch = new MatchEthernetType(NwConstants.ETHTYPE_IPV6);
flowMatches.add(ipv6EthMatch);
MatchIpv6Source srcMatch = new MatchIpv6Source(aap.getIpAddress().getIpPrefix().getIpv6Prefix());
flowMatches.add(srcMatch);
}
}
return flowMatches;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs in project netvirt by opendaylight.
the class AclServiceUtils method isIPv4Address.
public static boolean isIPv4Address(AllowedAddressPairs aap) {
IpPrefixOrAddress ipPrefixOrAddress = aap.getIpAddress();
IpPrefix ipPrefix = ipPrefixOrAddress.getIpPrefix();
if (ipPrefix != null) {
if (ipPrefix.getIpv4Prefix() != null) {
return true;
}
} else {
IpAddress ipAddress = ipPrefixOrAddress.getIpAddress();
if (ipAddress != null && ipAddress.getIpv4Address() != null) {
return true;
}
}
return false;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs in project netvirt by opendaylight.
the class AclServiceUtils method doesIpv4AddressExists.
/**
* Does IPv4 address exists in the list of allowed address pair.
*
* @param aaps the allowed address pairs
* @return true, if successful
*/
public static boolean doesIpv4AddressExists(List<AllowedAddressPairs> aaps) {
if (aaps == null) {
return false;
}
for (AllowedAddressPairs aap : aaps) {
IpPrefixOrAddress ipPrefixOrAddress = aap.getIpAddress();
IpPrefix ipPrefix = ipPrefixOrAddress.getIpPrefix();
if (ipPrefix != null) {
if (ipPrefix.getIpv4Prefix() != null) {
return true;
}
} else {
IpAddress ipAddress = ipPrefixOrAddress.getIpAddress();
if (ipAddress != null && ipAddress.getIpv4Address() != null) {
return true;
}
}
}
return false;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs in project netvirt by opendaylight.
the class AclServiceUtils method buildIpAndDstServiceMatch.
public static List<? extends MatchInfoBase> buildIpAndDstServiceMatch(Integer aclTag, AllowedAddressPairs aap) {
List<MatchInfoBase> flowMatches = new ArrayList<>();
flowMatches.add(buildRemoteAclTagMetadataMatch(aclTag));
if (aap.getIpAddress().getIpAddress() != null) {
if (aap.getIpAddress().getIpAddress().getIpv4Address() != null) {
MatchEthernetType ipv4EthMatch = new MatchEthernetType(NwConstants.ETHTYPE_IPV4);
flowMatches.add(ipv4EthMatch);
MatchIpv4Destination dstMatch = new MatchIpv4Destination(new Ipv4Prefix(aap.getIpAddress().getIpAddress().getIpv4Address().getValue() + "/32"));
flowMatches.add(dstMatch);
} else if (aap.getIpAddress().getIpAddress().getIpv6Address() != null) {
MatchEthernetType ipv6EthMatch = new MatchEthernetType(NwConstants.ETHTYPE_IPV6);
flowMatches.add(ipv6EthMatch);
MatchIpv6Destination dstMatch = new MatchIpv6Destination(new Ipv6Prefix(aap.getIpAddress().getIpAddress().getIpv6Address().getValue() + "/128"));
flowMatches.add(dstMatch);
}
} else if (aap.getIpAddress().getIpPrefix() != null) {
if (aap.getIpAddress().getIpPrefix().getIpv4Prefix() != null) {
MatchEthernetType ipv4EthMatch = new MatchEthernetType(NwConstants.ETHTYPE_IPV4);
flowMatches.add(ipv4EthMatch);
MatchIpv4Destination dstMatch = new MatchIpv4Destination(aap.getIpAddress().getIpPrefix().getIpv4Prefix());
flowMatches.add(dstMatch);
} else if (aap.getIpAddress().getIpPrefix().getIpv6Prefix() != null) {
MatchEthernetType ipv6EthMatch = new MatchEthernetType(NwConstants.ETHTYPE_IPV6);
flowMatches.add(ipv6EthMatch);
MatchIpv6Destination dstMatch = new MatchIpv6Destination(aap.getIpAddress().getIpPrefix().getIpv6Prefix());
flowMatches.add(dstMatch);
}
}
return flowMatches;
}
Aggregations