use of org.opendaylight.genius.mdsalutil.MatchInfoBase in project netvirt by opendaylight.
the class AclServiceUtils method buildBroadcastIpV4Matches.
public static List<MatchInfoBase> buildBroadcastIpV4Matches(String ipAddr) {
List<MatchInfoBase> matches = new ArrayList<>(2);
matches.add(new MatchEthernetDestination(new MacAddress(AclConstants.BROADCAST_MAC)));
matches.addAll(AclServiceUtils.buildIpMatches(new IpPrefixOrAddress(ipAddr.toCharArray()), MatchCriteria.MATCH_DESTINATION));
return matches;
}
use of org.opendaylight.genius.mdsalutil.MatchInfoBase 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.MatchInfoBase 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.genius.mdsalutil.MatchInfoBase in project netvirt by opendaylight.
the class AclServiceUtils method buildDhcpMatches.
/**
* Returns the DHCP match.
*
* @param srcPort the source port.
* @param dstPort the destination port.
* @param lportTag the lport tag
* @param serviceMode ingress or egress service
* @return list of matches.
*/
public static List<MatchInfoBase> buildDhcpMatches(int srcPort, int dstPort, int lportTag, Class<? extends ServiceModeBase> serviceMode) {
List<MatchInfoBase> matches = new ArrayList<>(5);
matches.add(MatchEthernetType.IPV4);
matches.add(MatchIpProtocol.UDP);
matches.add(new MatchUdpDestinationPort(dstPort));
matches.add(new MatchUdpSourcePort(srcPort));
matches.add(AclServiceUtils.buildLPortTagMatch(lportTag, serviceMode));
return matches;
}
use of org.opendaylight.genius.mdsalutil.MatchInfoBase 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