import org.opendaylight.genius.mdsalutil.MatchInfo;
import org.opendaylight.genius.mdsalutil.MatchInfoBase;
import org.opendaylight.genius.mdsalutil.NwConstants;
+import org.opendaylight.genius.mdsalutil.NxMatchFieldType;
+import org.opendaylight.genius.mdsalutil.NxMatchInfo;
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;
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.ace.type.AceIp;
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.ace.type.ace.ip.ace.ip.version.AceIpv4;
public static Map<String, List<MatchInfoBase>> programIpFlow(Matches matches) {
if (matches != null) {
AceIp acl = (AceIp) matches.getAceType();
- if (acl.getProtocol() == NwConstants.IP_PROT_TCP) {
+ Short protocol = acl.getProtocol();
+ if (protocol == null) {
+ return programEtherFlow(acl);
+ } else if (acl.getProtocol() == NwConstants.IP_PROT_TCP) {
return programTcpFlow(acl);
} else if (acl.getProtocol() == NwConstants.IP_PROT_UDP) {
return programUdpFlow(acl);
return null;
}
+ /** Converts ether matches to flows.
+ * @param acl the access control list
+ * @return the map containing the flows and the respective flow id
+ */
+ public static Map<String,List<MatchInfoBase>> programEtherFlow(AceIp acl) {
+ List<MatchInfoBase> flowMatches = new ArrayList<>();
+ flowMatches.addAll(addSrcIpMatches(acl));
+ flowMatches.addAll(addDstIpMatches(acl));
+ String flowId = "ETHER" + acl.getProtocol();
+ Map<String,List<MatchInfoBase>> flowMatchesMap = new HashMap<>();
+ flowMatchesMap.put(flowId,flowMatches);
+ return flowMatchesMap;
+ }
+
/** Converts generic protocol matches to flows.
*
* @param acl the access control list
List<MatchInfoBase> flowMatches = new ArrayList<>();
flowMatches.addAll(addSrcIpMatches(acl));
flowMatches.addAll(addDstIpMatches(acl));
- flowMatches.add(new MatchInfo(MatchFieldType.tcp_src,
- new long[] { port}));
- /*flowMatches.add(new NxMatchInfo(NxMatchFieldType.nx_tcp_src_with_mask,
- new long[] { port, portMaskMap.get(port) }));*/
+ flowMatches.add(new NxMatchInfo(NxMatchFieldType.nx_tcp_src_with_mask,
+ new long[] { port, portMaskMap.get(port) }));
flowMatches.add(new MatchInfo(MatchFieldType.ip_proto,
new long[] { acl.getProtocol() }));
String flowId = "TCP_SOURCE_" + port + "_" + portMaskMap.get(port);
List<MatchInfoBase> flowMatches = new ArrayList<>();
flowMatches.addAll(addSrcIpMatches(acl));
flowMatches.addAll(addDstIpMatches(acl));
- flowMatches.add(new MatchInfo(MatchFieldType.tcp_dst,
- new long[] { port}));
- /*flowMatches.add(new NxMatchInfo(NxMatchFieldType.nx_tcp_dst_with_mask,
- new long[] { port, portMaskMap.get(port) }));*/
+ flowMatches.add(new NxMatchInfo(NxMatchFieldType.nx_tcp_dst_with_mask,
+ new long[] { port, portMaskMap.get(port) }));
flowMatches.add(new MatchInfo(MatchFieldType.ip_proto,
new long[] { acl.getProtocol() }));
String flowId = "TCP_DESTINATION_" + port + "_" + portMaskMap.get(port);
List<MatchInfoBase> flowMatches = new ArrayList<>();
flowMatches.addAll(addSrcIpMatches(acl));
flowMatches.addAll(addDstIpMatches(acl));
- flowMatches.add(new MatchInfo(MatchFieldType.udp_src,
- new long[] { port}));
- /*flowMatches.add(new NxMatchInfo(NxMatchFieldType.nx_udp_src_with_mask,
- new long[] { port, portMaskMap.get(port) }));*/
+ flowMatches.add(new NxMatchInfo(NxMatchFieldType.nx_udp_src_with_mask,
+ new long[] { port, portMaskMap.get(port) }));
flowMatches.add(new MatchInfo(MatchFieldType.ip_proto,
new long[] { acl.getProtocol() }));
String flowId = "UDP_SOURCE_" + port + "_" + portMaskMap.get(port);
List<MatchInfoBase> flowMatches = new ArrayList<>();
flowMatches.addAll(addSrcIpMatches(acl));
flowMatches.addAll(addDstIpMatches(acl));
- flowMatches.add(new MatchInfo(MatchFieldType.udp_dst,
- new long[] { port}));
- /*flowMatches.add(new NxMatchInfo(NxMatchFieldType.nx_udp_dst_with_mask,
- new long[] { port, portMaskMap.get(port) }));*/
+ flowMatches.add(new NxMatchInfo(NxMatchFieldType.nx_udp_dst_with_mask,
+ new long[] { port, portMaskMap.get(port) }));
flowMatches.add(new MatchInfo(MatchFieldType.ip_proto,
new long[] { acl.getProtocol() }));
String flowId = "UDP_DESTINATION_" + port + "_" + portMaskMap.get(port);
flowMatches.add(new MatchInfo(MatchFieldType.eth_type,
new long[] { NwConstants.ETHTYPE_IPV4 }));
Ipv4Prefix srcNetwork = ((AceIpv4)acl.getAceIpVersion()).getSourceIpv4Network();
- if (null != srcNetwork) {
+ if (null != srcNetwork && !srcNetwork.getValue().equals(AclConstants.IPV4_ALL_NETWORK)) {
String[] ipaddressValues = srcNetwork.getValue().split("/");
flowMatches.add(new MatchInfo(MatchFieldType.ipv4_source,
new String[] {ipaddressValues[0], ipaddressValues[1]}));
new long[] { NwConstants.ETHTYPE_IPV6 }));
Ipv6Prefix srcNetwork = ((AceIpv6)acl.getAceIpVersion()).getSourceIpv6Network();
if (null != srcNetwork) {
- // TODO Ipv6 Match.
+ flowMatches.add(new MatchInfo(MatchFieldType.ipv6_source,
+ new String[] {srcNetwork.getValue()}));
}
}
return flowMatches;
flowMatches.add(new MatchInfo(MatchFieldType.eth_type,
new long[] { NwConstants.ETHTYPE_IPV4 }));
Ipv4Prefix dstNetwork = ((AceIpv4)acl.getAceIpVersion()).getDestinationIpv4Network();
- if (null != dstNetwork) {
+ if (null != dstNetwork && !dstNetwork.getValue().equals(AclConstants.IPV4_ALL_NETWORK)) {
String[] ipaddressValues = dstNetwork.getValue().split("/");
flowMatches.add(new MatchInfo(MatchFieldType.ipv4_destination,
new String[] {ipaddressValues[0], ipaddressValues[1]}));
new long[] { NwConstants.ETHTYPE_IPV6 }));
Ipv6Prefix dstNetwork = ((AceIpv6)acl.getAceIpVersion()).getDestinationIpv6Network();
if (null != dstNetwork) {
- // TODO Ipv6 Match.
+ flowMatches.add(new MatchInfo(MatchFieldType.ipv6_destination,
+ new String[] {dstNetwork.getValue()}));
}
}
return flowMatches;