use of org.opendaylight.genius.mdsalutil.matches.MatchIpv6Source in project netvirt by opendaylight.
the class CountersServiceUtils method buildIpMatches.
private static List<MatchInfoBase> buildIpMatches(String ip, ElementCountersDirection direction) {
List<MatchInfoBase> flowMatches = new ArrayList<>();
IpAddress ipAddress = new IpAddress(ip.toCharArray());
if (ipAddress.getIpv4Address() != null) {
flowMatches.add(MatchEthernetType.IPV4);
flowMatches.add(direction == ElementCountersDirection.EGRESS ? new MatchIpv4Source(ipAddress.getIpv4Address().getValue(), "32") : new MatchIpv4Destination(ipAddress.getIpv4Address().getValue(), "32"));
} else {
flowMatches.add(MatchEthernetType.IPV6);
flowMatches.add(direction == ElementCountersDirection.EGRESS ? new MatchIpv6Source(ipAddress.getIpv6Address().getValue() + "/128") : new MatchIpv6Destination(ipAddress.getIpv6Address().getValue() + "/128"));
}
return flowMatches;
}
use of org.opendaylight.genius.mdsalutil.matches.MatchIpv6Source in project netvirt by opendaylight.
the class AclServiceOFFlowBuilder method addSrcIpMatches.
/**
* Adds source ip matches to the flows.
* @param acl the access control list
* @return the list of flows.
*/
public static List<MatchInfoBase> addSrcIpMatches(AceIp acl) {
List<MatchInfoBase> flowMatches = new ArrayList<>();
if (acl.getAceIpVersion() instanceof AceIpv4) {
flowMatches.add(MatchEthernetType.IPV4);
Ipv4Prefix srcNetwork = ((AceIpv4) acl.getAceIpVersion()).getSourceIpv4Network();
if (null != srcNetwork && !srcNetwork.getValue().equals(AclConstants.IPV4_ALL_NETWORK)) {
flowMatches.add(new MatchIpv4Source(srcNetwork));
}
} else if (acl.getAceIpVersion() instanceof AceIpv6) {
flowMatches.add(MatchEthernetType.IPV6);
Ipv6Prefix srcNetwork = ((AceIpv6) acl.getAceIpVersion()).getSourceIpv6Network();
if (null != srcNetwork && !srcNetwork.getValue().equals(AclConstants.IPV6_ALL_NETWORK)) {
flowMatches.add(new MatchIpv6Source(srcNetwork));
}
}
return flowMatches;
}
use of org.opendaylight.genius.mdsalutil.matches.MatchIpv6Source in project netvirt by opendaylight.
the class AclServiceUtils method buildIpMatches.
/**
* Builds the ip matches.
*
* @param ipPrefixOrAddress the ip prefix or address
* @param matchCriteria the source_ip or destination_ip used for the match
* @return the list
*/
public static List<MatchInfoBase> buildIpMatches(IpPrefixOrAddress ipPrefixOrAddress, MatchCriteria matchCriteria) {
List<MatchInfoBase> flowMatches = new ArrayList<>();
IpPrefix ipPrefix = ipPrefixOrAddress.getIpPrefix();
if (ipPrefix != null) {
Ipv4Prefix ipv4Prefix = ipPrefix.getIpv4Prefix();
if (ipv4Prefix != null) {
flowMatches.add(MatchEthernetType.IPV4);
if (!ipv4Prefix.getValue().equals(AclConstants.IPV4_ALL_NETWORK)) {
flowMatches.add(matchCriteria == MatchCriteria.MATCH_SOURCE ? new MatchIpv4Source(ipv4Prefix) : new MatchIpv4Destination(ipv4Prefix));
}
} else {
flowMatches.add(MatchEthernetType.IPV6);
flowMatches.add(matchCriteria == MatchCriteria.MATCH_SOURCE ? new MatchIpv6Source(ipPrefix.getIpv6Prefix()) : new MatchIpv6Destination(ipPrefix.getIpv6Prefix()));
}
} else {
IpAddress ipAddress = ipPrefixOrAddress.getIpAddress();
if (ipAddress.getIpv4Address() != null) {
flowMatches.add(MatchEthernetType.IPV4);
flowMatches.add(matchCriteria == MatchCriteria.MATCH_SOURCE ? new MatchIpv4Source(ipAddress.getIpv4Address().getValue(), "32") : new MatchIpv4Destination(ipAddress.getIpv4Address().getValue(), "32"));
} else {
flowMatches.add(MatchEthernetType.IPV6);
flowMatches.add(matchCriteria == MatchCriteria.MATCH_SOURCE ? new MatchIpv6Source(ipAddress.getIpv6Address().getValue() + "/128") : new MatchIpv6Destination(ipAddress.getIpv6Address().getValue() + "/128"));
}
}
return flowMatches;
}
use of org.opendaylight.genius.mdsalutil.matches.MatchIpv6Source 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;
}
Aggregations