Added cubby-holes for new projects.
diff --git a/of-save/lib/src/main/java/org/projectfloodlight/openflow/protocol/match/Match.java b/of-save/lib/src/main/java/org/projectfloodlight/openflow/protocol/match/Match.java
new file mode 100644
index 0000000..0efdcbb
--- /dev/null
+++ b/of-save/lib/src/main/java/org/projectfloodlight/openflow/protocol/match/Match.java
@@ -0,0 +1,216 @@
+package org.projectfloodlight.openflow.protocol.match;
+
+import org.projectfloodlight.openflow.protocol.OFObject;
+import org.projectfloodlight.openflow.types.Masked;
+import org.projectfloodlight.openflow.types.OFValueType;
+
+/**
+ * Generic interface for version-agnostic immutable Match structure.
+ * The Match structure is defined in the OpenFlow protocol, and it contains information on
+ * the fields to be matched in a specific flow record.
+ * This interface does not assume anything on the fields in the Match structure. If in
+ * some version, the match structure cannot handle a certain field, it may return <code>false</code>
+ * for <code>supports(...)</code> calls, and throw <code>UnsupportedOperationException</code> from all
+ * other methods in such cases.
+ * <br><br>
+ * On wildcards and masks:<br>
+ * This interface defines the following masking notations for fields:
+ * <ul>
+ * <li><b>Exact</b>: field is matched exactly against a single, fixed value (no mask, or mask is all ones).
+ * <li><b>Wildcarded</b>: field is not being matched. It is fully masked (mask=0) and any value of it
+ * will match the flow record having this match.
+ * <li><b>Partially masked</b>: field is matched using a specified mask which is neither 0 nor all ones. Mask can
+ * be either arbitrary or require some specific structure.
+ * </ul>
+ * Implementing classes may or may not support all types of these masking types. They may also support
+ * them in part. For example, OF1.0 supports exact match and (full) wildcarding for all fields, but it
+ * does only supports partial masking for IP source/destination fields, and this partial masking must be
+ * in the CIDR prefix format. Thus, OF1.0 implementation may throw <code>UnsupportedOperationException</code> if given
+ * in <code>setMasked</code> an IP mask of, for example, 255.0.255.0, or if <code>setMasked</code> is called for any field
+ * which is not IP source/destination address.
+ * <br><br>
+ * On prerequisites:<br>
+ * From the OF1.1 spec, page 28, the OF1.0 spec failed to explicitly specify this, but it
+ * is the behavior of OF1.0 switches:
+ * "Protocol-specific fields within ofp_match will be ignored within a single table when
+ * the corresponding protocol is not specified in the match. The MPLS match fields will
+ * be ignored unless the Ethertype is specified as MPLS. Likewise, the IP header and
+ * transport header fields will be ignored unless the Ethertype is specified as either
+ * IPv4 or ARP. The tp_src and tp_dst fields will be ignored unless the network protocol
+ * specified is as TCP, UDP or SCTP. Fields that are ignored don't need to be wildcarded
+ * and should be set to 0."
+ * <br><br>
+ * This interface uses generics to assure type safety in users code. However, implementing classes may have to suppress
+ * 'unchecked cast' warnings while making sure they correctly cast base on their implementation details.
+ *
+ * @author Yotam Harchol (yotam.harchol@bigswitch.com)
+ */
+public interface Match extends OFObject {
+
+ /**
+ * Returns a value for the given field if:
+ * <ul>
+ * <li>Field is supported
+ * <li>Field is not fully wildcarded
+ * <li>Prerequisites are ok
+ * </ul>
+ * If one of the above conditions does not hold, returns null. Value is returned masked if partially wildcarded.
+ *
+ * @param field Match field to retrieve
+ * @return Value of match field (may be masked), or <code>null</code> if field is one of the conditions above does not hold.
+ * @throws UnsupportedOperationException If field is not supported.
+ */
+ public <F extends OFValueType<F>> F get(MatchField<F> field) throws UnsupportedOperationException;
+
+ /**
+ * Returns the masked value for the given field from this match, along with the mask itself.
+ * Prerequisite: field is partially masked.
+ * If prerequisite is not met, a <code>null</code> is returned.
+ *
+ * @param field Match field to retrieve.
+ * @return Masked value of match field or null if no mask is set.
+ * @throws UnsupportedOperationException If field is not supported.
+ */
+ public <F extends OFValueType<F>> Masked<F> getMasked(MatchField<F> field) throws UnsupportedOperationException;
+
+ /**
+ * Returns true if and only if this match object supports the given match field.
+ *
+ * @param field Match field
+ * @return true if field is supported, false otherwise.
+ */
+ public boolean supports(MatchField<?> field);
+
+ /**
+ * Returns true if and only if this match object supports partially bitmasking of the given field.
+ * (note: not all possible values of this bitmask have to be acceptable)
+ *
+ * @param field Match field.
+ * @return true if field can be partially masked, false otherwise.
+ * @throws UnsupportedOperationException If field is not supported.
+ */
+ public boolean supportsMasked(MatchField<?> field) throws UnsupportedOperationException;
+
+ /**
+ * Returns true if and only if this field is currently specified in the match with an exact value and
+ * no mask. I.e., the specified match will only select packets that match the exact value of getValue(field).
+ *
+ * @param field Match field.
+ * @return true if field has a specific exact value, false if not.
+ * @throws UnsupportedOperationException If field is not supported.
+ */
+ public boolean isExact(MatchField<?> field) throws UnsupportedOperationException;
+
+ /**
+ * True if and only if this field is currently logically unspecified in the match, i.e, the
+ * value returned by getValue(f) has no impact on whether a packet will be selected
+ * by the match or not.
+ *
+ * @param field Match field.
+ * @return true if field is fully wildcarded, false if not.
+ * @throws UnsupportedOperationException If field is not supported.
+ */
+ public boolean isFullyWildcarded(MatchField<?> field) throws UnsupportedOperationException;
+
+ /**
+ * True if and only if this field is currently partially specified in the match, i.e, the
+ * match will only select packets that match (p.value & getMask(field)) == getValue(field),
+ * and getMask(field) != 0.
+ *
+ * @param field Match field.
+ * @return true if field is partially masked, false if not.
+ * @throws UnsupportedOperationException If field is not supported.
+ */
+ public boolean isPartiallyMasked(MatchField<?> field) throws UnsupportedOperationException;
+
+ /**
+ * Get an Iterable over the match fields that have been specified for the
+ * match. This includes the match fields that are exact or masked match
+ * (but not fully wildcarded).
+ *
+ * @return
+ */
+ public Iterable<MatchField<?>> getMatchFields();
+
+ /**
+ * Returns a builder to build new instances of this type of match object.
+ * @return Match builder
+ */
+ public Builder createBuilder();
+
+ /**
+ * Builder interface for Match objects.
+ * Builder is used to create new Match objects and it creates the match according to the version it
+ * corresponds to. The builder uses the same notation of wildcards and masks, and can also throw
+ * <code>UnsupportedOperationException</code> if it is asked to create some matching that is not supported in
+ * the version it represents.
+ *
+ * While used, MatchBuilder may not be consistent in terms of field prerequisites. However, user must
+ * solve these before using the generated Match object as these prerequisites should be enforced in the
+ * getters.
+ *
+ * @author Yotam Harchol (yotam.harchol@bigswitch.com)
+ */
+ interface Builder {
+ public <F extends OFValueType<F>> F get(MatchField<F> field) throws UnsupportedOperationException;
+
+ public <F extends OFValueType<F>> Masked<F> getMasked(MatchField<F> field) throws UnsupportedOperationException;
+
+ public boolean supports(MatchField<?> field);
+
+ public boolean supportsMasked(MatchField<?> field) throws UnsupportedOperationException;
+
+ public boolean isExact(MatchField<?> field) throws UnsupportedOperationException;
+
+ public boolean isFullyWildcarded(MatchField<?> field) throws UnsupportedOperationException;
+
+ public boolean isPartiallyMasked(MatchField<?> field) throws UnsupportedOperationException;
+
+ /**
+ * Sets a specific exact value for a field.
+ *
+ * @param field Match field to set.
+ * @param value Value of match field.
+ * @return the Builder instance used.
+ * @throws UnsupportedOperationException If field is not supported.
+ */
+ public <F extends OFValueType<F>> Builder setExact(MatchField<F> field, F value) throws UnsupportedOperationException;
+
+ /**
+ * Sets a masked value for a field.
+ *
+ * @param field Match field to set.
+ * @param value Value of field.
+ * @param mask Mask value.
+ * @return the Builder instance used.
+ * @throws UnsupportedOperationException If field is not supported, if field is supported but does not support masking, or if mask structure is not supported.
+ */
+ public <F extends OFValueType<F>> Builder setMasked(MatchField<F> field, F value, F mask) throws UnsupportedOperationException;
+
+ /**
+ * Sets a masked value for a field.
+ *
+ * @param field Match field to set.
+ * @param valueWithMask Compound Masked object contains the value and the mask.
+ * @return the Builder instance used.
+ * @throws UnsupportedOperationException If field is not supported, if field is supported but does not support masking, or if mask structure is not supported.
+ */
+ public <F extends OFValueType<F>> Builder setMasked(MatchField<F> field, Masked<F> valueWithMask) throws UnsupportedOperationException;
+
+ /**
+ * Unsets any value given for the field and wildcards it so that it matches any value.
+ *
+ * @param field Match field to unset.
+ * @return the Builder instance used.
+ * @throws UnsupportedOperationException If field is not supported.
+ */
+ public <F extends OFValueType<F>> Builder wildcard(MatchField<F> field) throws UnsupportedOperationException;
+
+ /**
+ * Returns the match created by this builder.
+ *
+ * @return a Match object.
+ */
+ public Match build();
+ }
+}
\ No newline at end of file
diff --git a/of-save/lib/src/main/java/org/projectfloodlight/openflow/protocol/match/MatchField.java b/of-save/lib/src/main/java/org/projectfloodlight/openflow/protocol/match/MatchField.java
new file mode 100644
index 0000000..78e6075
--- /dev/null
+++ b/of-save/lib/src/main/java/org/projectfloodlight/openflow/protocol/match/MatchField.java
@@ -0,0 +1,251 @@
+package org.projectfloodlight.openflow.protocol.match;
+
+import org.projectfloodlight.openflow.types.ArpOpcode;
+import org.projectfloodlight.openflow.types.ClassId;
+import org.projectfloodlight.openflow.types.EthType;
+import org.projectfloodlight.openflow.types.ICMPv4Code;
+import org.projectfloodlight.openflow.types.ICMPv4Type;
+import org.projectfloodlight.openflow.types.IPv4Address;
+import org.projectfloodlight.openflow.types.IPv6Address;
+import org.projectfloodlight.openflow.types.IPv6FlowLabel;
+import org.projectfloodlight.openflow.types.IpDscp;
+import org.projectfloodlight.openflow.types.IpEcn;
+import org.projectfloodlight.openflow.types.IpProtocol;
+import org.projectfloodlight.openflow.types.LagId;
+import org.projectfloodlight.openflow.types.MacAddress;
+import org.projectfloodlight.openflow.types.OFBitMask128;
+import org.projectfloodlight.openflow.types.OFBooleanValue;
+import org.projectfloodlight.openflow.types.OFMetadata;
+import org.projectfloodlight.openflow.types.OFPort;
+import org.projectfloodlight.openflow.types.OFValueType;
+import org.projectfloodlight.openflow.types.OFVlanVidMatch;
+import org.projectfloodlight.openflow.types.TransportPort;
+import org.projectfloodlight.openflow.types.U16;
+import org.projectfloodlight.openflow.types.U64;
+import org.projectfloodlight.openflow.types.U32;
+import org.projectfloodlight.openflow.types.U8;
+import org.projectfloodlight.openflow.types.UDF;
+import org.projectfloodlight.openflow.types.VRF;
+import org.projectfloodlight.openflow.types.VlanPcp;
+
+@SuppressWarnings("unchecked")
+public class MatchField<F extends OFValueType<F>> {
+ private final String name;
+ public final MatchFields id;
+ private final Prerequisite<?>[] prerequisites;
+
+ private MatchField(final String name, final MatchFields id, Prerequisite<?>... prerequisites) {
+ this.name = name;
+ this.id = id;
+ this.prerequisites = prerequisites;
+ }
+
+ public final static MatchField<OFPort> IN_PORT =
+ new MatchField<OFPort>("in_port", MatchFields.IN_PORT);
+
+ public final static MatchField<OFPort> IN_PHY_PORT =
+ new MatchField<OFPort>("in_phy_port", MatchFields.IN_PHY_PORT,
+ new Prerequisite<OFPort>(MatchField.IN_PORT));
+
+ public final static MatchField<OFMetadata> METADATA =
+ new MatchField<OFMetadata>("metadata", MatchFields.METADATA);
+
+ public final static MatchField<MacAddress> ETH_DST =
+ new MatchField<MacAddress>("eth_dst", MatchFields.ETH_DST);
+
+ public final static MatchField<MacAddress> ETH_SRC =
+ new MatchField<MacAddress>("eth_src", MatchFields.ETH_SRC);
+
+ public final static MatchField<EthType> ETH_TYPE =
+ new MatchField<EthType>("eth_type", MatchFields.ETH_TYPE);
+
+ public final static MatchField<OFVlanVidMatch> VLAN_VID =
+ new MatchField<OFVlanVidMatch>("vlan_vid", MatchFields.VLAN_VID);
+
+ public final static MatchField<VlanPcp> VLAN_PCP =
+ new MatchField<VlanPcp>("vlan_pcp", MatchFields.VLAN_PCP,
+ new Prerequisite<OFVlanVidMatch>(MatchField.VLAN_VID));
+
+ public final static MatchField<IpDscp> IP_DSCP =
+ new MatchField<IpDscp>("ip_dscp", MatchFields.IP_DSCP,
+ new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.IPv4, EthType.IPv6));
+
+ public final static MatchField<IpEcn> IP_ECN =
+ new MatchField<IpEcn>("ip_ecn", MatchFields.IP_ECN,
+ new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.IPv4, EthType.IPv6));
+
+ public final static MatchField<IpProtocol> IP_PROTO =
+ new MatchField<IpProtocol>("ip_proto", MatchFields.IP_PROTO,
+ new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.IPv4, EthType.IPv6));
+
+ public final static MatchField<IPv4Address> IPV4_SRC =
+ new MatchField<IPv4Address>("ipv4_src", MatchFields.IPV4_SRC,
+ new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.IPv4));
+
+ public final static MatchField<IPv4Address> IPV4_DST =
+ new MatchField<IPv4Address>("ipv4_dst", MatchFields.IPV4_DST,
+ new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.IPv4));
+
+ public final static MatchField<TransportPort> TCP_SRC = new MatchField<TransportPort>(
+ "tcp_src", MatchFields.TCP_SRC,
+ new Prerequisite<IpProtocol>(MatchField.IP_PROTO, IpProtocol.TCP));
+
+ public final static MatchField<TransportPort> TCP_DST = new MatchField<TransportPort>(
+ "tcp_dst", MatchFields.TCP_DST,
+ new Prerequisite<IpProtocol>(MatchField.IP_PROTO, IpProtocol.TCP));
+
+ public final static MatchField<TransportPort> UDP_SRC = new MatchField<TransportPort>(
+ "udp_src", MatchFields.UDP_SRC,
+ new Prerequisite<IpProtocol>(MatchField.IP_PROTO, IpProtocol.UDP));
+
+ public final static MatchField<TransportPort> UDP_DST = new MatchField<TransportPort>(
+ "udp_dst", MatchFields.UDP_DST,
+ new Prerequisite<IpProtocol>(MatchField.IP_PROTO, IpProtocol.UDP));
+
+ public final static MatchField<TransportPort> SCTP_SRC = new MatchField<TransportPort>(
+ "sctp_src", MatchFields.SCTP_SRC,
+ new Prerequisite<IpProtocol>(MatchField.IP_PROTO, IpProtocol.SCTP));
+
+ public final static MatchField<TransportPort> SCTP_DST = new MatchField<TransportPort>(
+ "sctp_dst", MatchFields.SCTP_DST,
+ new Prerequisite<IpProtocol>(MatchField.IP_PROTO, IpProtocol.SCTP));
+
+ public final static MatchField<ICMPv4Type> ICMPV4_TYPE = new MatchField<ICMPv4Type>(
+ "icmpv4_type", MatchFields.ICMPV4_TYPE,
+ new Prerequisite<IpProtocol>(MatchField.IP_PROTO, IpProtocol.ICMP));
+
+ public final static MatchField<ICMPv4Code> ICMPV4_CODE = new MatchField<ICMPv4Code>(
+ "icmpv4_code", MatchFields.ICMPV4_CODE,
+ new Prerequisite<IpProtocol>(MatchField.IP_PROTO, IpProtocol.ICMP));
+
+ public final static MatchField<ArpOpcode> ARP_OP = new MatchField<ArpOpcode>(
+ "arp_op", MatchFields.ARP_OP,
+ new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.ARP));
+
+ public final static MatchField<IPv4Address> ARP_SPA =
+ new MatchField<IPv4Address>("arp_spa", MatchFields.ARP_SPA,
+ new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.ARP));
+
+ public final static MatchField<IPv4Address> ARP_TPA =
+ new MatchField<IPv4Address>("arp_tpa", MatchFields.ARP_TPA,
+ new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.ARP));
+
+ public final static MatchField<MacAddress> ARP_SHA =
+ new MatchField<MacAddress>("arp_sha", MatchFields.ARP_SHA,
+ new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.ARP));
+
+ public final static MatchField<MacAddress> ARP_THA =
+ new MatchField<MacAddress>("arp_tha", MatchFields.ARP_THA,
+ new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.ARP));
+
+ public final static MatchField<IPv6Address> IPV6_SRC =
+ new MatchField<IPv6Address>("ipv6_src", MatchFields.IPV6_SRC,
+ new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.IPv6));
+
+ public final static MatchField<IPv6Address> IPV6_DST =
+ new MatchField<IPv6Address>("ipv6_dst", MatchFields.IPV6_DST,
+ new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.IPv6));
+
+ public final static MatchField<IPv6FlowLabel> IPV6_FLABEL =
+ new MatchField<IPv6FlowLabel>("ipv6_flabel", MatchFields.IPV6_FLABEL,
+ new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.IPv6));
+
+ public final static MatchField<U8> ICMPV6_TYPE =
+ new MatchField<U8>("icmpv6_type", MatchFields.ICMPV6_TYPE,
+ new Prerequisite<IpProtocol>(MatchField.IP_PROTO, IpProtocol.IPv6_ICMP));
+
+ public final static MatchField<U8> ICMPV6_CODE =
+ new MatchField<U8>("icmpv6_code", MatchFields.ICMPV6_CODE,
+ new Prerequisite<IpProtocol>(MatchField.IP_PROTO, IpProtocol.IPv6_ICMP));
+
+ public final static MatchField<IPv6Address> IPV6_ND_TARGET =
+ new MatchField<IPv6Address>("ipv6_nd_target", MatchFields.IPV6_ND_TARGET,
+ new Prerequisite<U8>(MatchField.ICMPV6_TYPE, U8.of((short)135), U8.of((short)136)));
+
+ public final static MatchField<MacAddress> IPV6_ND_SLL =
+ new MatchField<MacAddress>("ipv6_nd_sll", MatchFields.IPV6_ND_SLL,
+ new Prerequisite<U8>(MatchField.ICMPV6_TYPE, U8.of((short)135)));
+
+ public final static MatchField<MacAddress> IPV6_ND_TLL =
+ new MatchField<MacAddress>("ipv6_nd_tll", MatchFields.IPV6_ND_TLL,
+ new Prerequisite<U8>(MatchField.ICMPV6_TYPE, U8.of((short)136)));
+
+ public final static MatchField<U32> MPLS_LABEL =
+ new MatchField<U32>("mpls_label", MatchFields.MPLS_LABEL,
+ new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.MPLS_UNICAST, EthType.MPLS_MULTICAST));
+
+ public final static MatchField<U8> MPLS_TC =
+ new MatchField<U8>("mpls_tc", MatchFields.MPLS_TC,
+ new Prerequisite<EthType>(MatchField.ETH_TYPE, EthType.MPLS_UNICAST, EthType.MPLS_MULTICAST));
+
+ public final static MatchField<U64> TUNNEL_ID =
+ new MatchField<U64>("tunnel_id", MatchFields.TUNNEL_ID);
+
+ public final static MatchField<OFBitMask128> BSN_IN_PORTS_128 =
+ new MatchField<OFBitMask128>("bsn_in_ports_128", MatchFields.BSN_IN_PORTS_128);
+
+ public final static MatchField<LagId> BSN_LAG_ID =
+ new MatchField<LagId>("bsn_lag_id", MatchFields.BSN_LAG_ID);
+
+ public final static MatchField<VRF> BSN_VRF =
+ new MatchField<VRF>("bsn_vrf", MatchFields.BSN_VRF);
+
+ public final static MatchField<OFBooleanValue> BSN_GLOBAL_VRF_ALLOWED =
+ new MatchField<OFBooleanValue>("bsn_global_vrf_allowed", MatchFields.BSN_GLOBAL_VRF_ALLOWED);
+
+ public final static MatchField<ClassId> BSN_L3_INTERFACE_CLASS_ID =
+ new MatchField<ClassId>("bsn_l3_interface_class_id", MatchFields.BSN_L3_INTERFACE_CLASS_ID);
+
+ public final static MatchField<ClassId> BSN_L3_SRC_CLASS_ID =
+ new MatchField<ClassId>("bsn_l3_src_class_id", MatchFields.BSN_L3_SRC_CLASS_ID);
+
+ public final static MatchField<ClassId> BSN_L3_DST_CLASS_ID =
+ new MatchField<ClassId>("bsn_l3_dst_class_id", MatchFields.BSN_L3_DST_CLASS_ID);
+
+ public final static MatchField<ClassId> BSN_EGR_PORT_GROUP_ID =
+ new MatchField<ClassId>("bsn_egr_port_group_id", MatchFields.BSN_EGR_PORT_GROUP_ID);
+
+ public final static MatchField<UDF> BSN_UDF0 =
+ new MatchField<UDF>("bsn_udf", MatchFields.BSN_UDF0);
+
+ public final static MatchField<UDF> BSN_UDF1 =
+ new MatchField<UDF>("bsn_udf", MatchFields.BSN_UDF1);
+
+ public final static MatchField<UDF> BSN_UDF2 =
+ new MatchField<UDF>("bsn_udf", MatchFields.BSN_UDF2);
+
+ public final static MatchField<UDF> BSN_UDF3 =
+ new MatchField<UDF>("bsn_udf", MatchFields.BSN_UDF3);
+
+ public final static MatchField<UDF> BSN_UDF4 =
+ new MatchField<UDF>("bsn_udf", MatchFields.BSN_UDF4);
+
+ public final static MatchField<UDF> BSN_UDF5 =
+ new MatchField<UDF>("bsn_udf", MatchFields.BSN_UDF5);
+
+ public final static MatchField<UDF> BSN_UDF6 =
+ new MatchField<UDF>("bsn_udf", MatchFields.BSN_UDF6);
+
+ public final static MatchField<UDF> BSN_UDF7 =
+ new MatchField<UDF>("bsn_udf", MatchFields.BSN_UDF7);
+
+ public final static MatchField<U16> BSN_TCP_FLAGS =
+ new MatchField<U16>("bsn_tcp_flags", MatchFields.BSN_TCP_FLAGS);
+
+ public final static MatchField<ClassId> BSN_VLAN_XLATE_PORT_GROUP_ID =
+ new MatchField<ClassId>("bsn_vlan_xlate_port_group_id", MatchFields.BSN_VLAN_XLATE_PORT_GROUP_ID);
+
+ public String getName() {
+ return name;
+ }
+
+ public boolean arePrerequisitesOK(Match match) {
+ for (Prerequisite<?> p : this.prerequisites) {
+ if (!p.isSatisfied(match)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+}
diff --git a/of-save/lib/src/main/java/org/projectfloodlight/openflow/protocol/match/MatchFields.java b/of-save/lib/src/main/java/org/projectfloodlight/openflow/protocol/match/MatchFields.java
new file mode 100644
index 0000000..863634e
--- /dev/null
+++ b/of-save/lib/src/main/java/org/projectfloodlight/openflow/protocol/match/MatchFields.java
@@ -0,0 +1,60 @@
+package org.projectfloodlight.openflow.protocol.match;
+
+// MUST BE ORDERED BY THE ORDER OF OF SPEC!!!
+public enum MatchFields {
+ IN_PORT,
+ IN_PHY_PORT,
+ METADATA,
+ ETH_DST,
+ ETH_SRC,
+ ETH_TYPE,
+ VLAN_VID,
+ VLAN_PCP,
+ IP_DSCP,
+ IP_ECN,
+ IP_PROTO,
+ IPV4_SRC,
+ IPV4_DST,
+ TCP_SRC,
+ TCP_DST,
+ UDP_SRC,
+ UDP_DST,
+ SCTP_SRC,
+ SCTP_DST,
+ ICMPV4_TYPE,
+ ICMPV4_CODE,
+ ARP_OP,
+ ARP_SPA,
+ ARP_TPA,
+ ARP_SHA,
+ ARP_THA,
+ IPV6_SRC,
+ IPV6_DST,
+ IPV6_FLABEL,
+ ICMPV6_TYPE,
+ ICMPV6_CODE,
+ IPV6_ND_TARGET,
+ IPV6_ND_SLL,
+ IPV6_ND_TLL,
+ MPLS_LABEL,
+ MPLS_TC,
+ TUNNEL_ID,
+ BSN_IN_PORTS_128,
+ BSN_LAG_ID,
+ BSN_VRF,
+ BSN_GLOBAL_VRF_ALLOWED,
+ BSN_L3_INTERFACE_CLASS_ID,
+ BSN_L3_SRC_CLASS_ID,
+ BSN_L3_DST_CLASS_ID,
+ BSN_EGR_PORT_GROUP_ID,
+ BSN_UDF0,
+ BSN_UDF1,
+ BSN_UDF2,
+ BSN_UDF3,
+ BSN_UDF4,
+ BSN_UDF5,
+ BSN_UDF6,
+ BSN_UDF7,
+ BSN_TCP_FLAGS,
+ BSN_VLAN_XLATE_PORT_GROUP_ID,
+}
diff --git a/of-save/lib/src/main/java/org/projectfloodlight/openflow/protocol/match/Prerequisite.java b/of-save/lib/src/main/java/org/projectfloodlight/openflow/protocol/match/Prerequisite.java
new file mode 100644
index 0000000..03d5e79
--- /dev/null
+++ b/of-save/lib/src/main/java/org/projectfloodlight/openflow/protocol/match/Prerequisite.java
@@ -0,0 +1,45 @@
+package org.projectfloodlight.openflow.protocol.match;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.projectfloodlight.openflow.types.OFValueType;
+
+public class Prerequisite<T extends OFValueType<T>> {
+ private final MatchField<T> field;
+ private final Set<OFValueType<T>> values;
+ private boolean any;
+
+ @SafeVarargs
+ public Prerequisite(MatchField<T> field, OFValueType<T>... values) {
+ this.values = new HashSet<OFValueType<T>>();
+ this.field = field;
+ if (values == null || values.length == 0) {
+ this.any = true;
+ } else {
+ this.any = false;
+ for (OFValueType<T> value : values) {
+ this.values.add(value);
+ }
+ }
+ }
+
+ /**
+ * Returns true if this prerequisite is satisfied by the given match object.
+ *
+ * @param match Match object
+ * @return true iff prerequisite is satisfied.
+ */
+ public boolean isSatisfied(Match match) {
+ OFValueType<T> res = match.get(this.field);
+ if (res == null)
+ return false;
+ if (this.any)
+ return true;
+ if (this.values.contains(res)) {
+ return true;
+ }
+ return false;
+ }
+
+}