blob: d35f709fa2e43593fecd73beca3b04282f381ee0 [file] [log] [blame]
Andreas Wundsam40e14f72013-05-06 14:49:08 -07001package org.openflow.protocol.match;
2
3import org.openflow.protocol.OFObject;
Yotam Harcholfb4bfb92013-08-01 14:02:04 -07004import org.openflow.types.Masked;
Yotam Harchold7b84202013-07-26 16:08:10 -07005import org.openflow.types.OFValueType;
Andreas Wundsam40e14f72013-05-06 14:49:08 -07006
7public interface Match extends OFObject {
Andreas Wundsama94273b2013-08-01 22:11:33 -07008
Yotam Harchol5c9d6f42013-08-01 11:09:20 -07009 /*
10 * Preconditions
Andreas Wundsama94273b2013-08-01 22:11:33 -070011 * On preconditions (from the OF1.1 spec, page 28, the OF1.0 spec failed to explicitly
Yotam Harchol5c9d6f42013-08-01 11:09:20 -070012 * specify this, but it is the behavior of Of1.0 switches):
Andreas Wundsama94273b2013-08-01 22:11:33 -070013 * Protocol-specific fields within ofp_match will be ignored within a single table when
14 * the corresponding protocol is not specified in the match. The MPLS match fields will
15 * be ignored unless the Ethertype is specified as MPLS. Likewise, the IP header and
16 * transport header fields will be ignored unless the Ethertype is specified as either
17 * IPv4 or ARP. The tp_src and tp_dst fields will be ignored unless the network protocol
18 * specified is as TCP, UDP or SCTP. Fields that are ignored don�t need to be wildcarded
Yotam Harchol5c9d6f42013-08-01 11:09:20 -070019 * and should be set to 0.
20 */
Andreas Wundsama94273b2013-08-01 22:11:33 -070021
Yotam Harchol5c9d6f42013-08-01 11:09:20 -070022 /**
23 * Returns the value for the given field from this match.
Andreas Wundsama94273b2013-08-01 22:11:33 -070024 *
Yotam Harchol5c9d6f42013-08-01 11:09:20 -070025 * @param field Match field to retrieve
26 * @return Value of match field
27 */
28 public <F extends OFValueType<F>> F get(MatchField<F> field) throws UnsupportedOperationException;
Andreas Wundsam40e14f72013-05-06 14:49:08 -070029
Yotam Harchol5c9d6f42013-08-01 11:09:20 -070030 /**
Yotam Harcholfb4bfb92013-08-01 14:02:04 -070031 * Returns the masked value for the given field from this match.
32 * Precondition: field is partially wildcarded.
Andreas Wundsama94273b2013-08-01 22:11:33 -070033 *
Yotam Harcholfb4bfb92013-08-01 14:02:04 -070034 * @param field Match field to retrieve
35 * @return Masked value of match field or null if no mask
36 */
37 public <F extends OFValueType<F>> Masked<F> getMasked(MatchField<F> field) throws UnsupportedOperationException;
38
39 /**
Yotam Harchol5c9d6f42013-08-01 11:09:20 -070040 * Returns true if this match object supports the given match field.
Andreas Wundsama94273b2013-08-01 22:11:33 -070041 *
Yotam Harchol5c9d6f42013-08-01 11:09:20 -070042 * @param field Match field
Andreas Wundsama94273b2013-08-01 22:11:33 -070043 * @return
Yotam Harchol5c9d6f42013-08-01 11:09:20 -070044 */
Yotam Harchold7b84202013-07-26 16:08:10 -070045 public boolean supports(MatchField<?> field);
Andreas Wundsam40e14f72013-05-06 14:49:08 -070046
Yotam Harchol5c9d6f42013-08-01 11:09:20 -070047 /**
Andreas Wundsama94273b2013-08-01 22:11:33 -070048 * true iff field supports a bitmask mask that wildcards part of the field
Yotam Harchol5c9d6f42013-08-01 11:09:20 -070049 * (note: not all possible values of this bitmask have to be acceptable)
Andreas Wundsama94273b2013-08-01 22:11:33 -070050 *
Yotam Harchol5c9d6f42013-08-01 11:09:20 -070051 * @param field Match field
Andreas Wundsama94273b2013-08-01 22:11:33 -070052 * @return
Yotam Harchol5c9d6f42013-08-01 11:09:20 -070053 */
Yotam Harchold7b84202013-07-26 16:08:10 -070054 public boolean supportsMasked(MatchField<?> field);
Andreas Wundsam40e14f72013-05-06 14:49:08 -070055
Yotam Harchol5c9d6f42013-08-01 11:09:20 -070056 /**
Andreas Wundsama94273b2013-08-01 22:11:33 -070057 * True iff this field is currently fully specified in the match, i.e., the
Yotam Harchol5c9d6f42013-08-01 11:09:20 -070058 * match will only select packets that match the exact value of getField(field).
Andreas Wundsama94273b2013-08-01 22:11:33 -070059 *
Yotam Harchol5c9d6f42013-08-01 11:09:20 -070060 * @param field Match field
Andreas Wundsama94273b2013-08-01 22:11:33 -070061 * @return
Yotam Harchol5c9d6f42013-08-01 11:09:20 -070062 */
Yotam Harchold7b84202013-07-26 16:08:10 -070063 public boolean isExact(MatchField<?> field);
Andreas Wundsam40e14f72013-05-06 14:49:08 -070064
Yotam Harchol5c9d6f42013-08-01 11:09:20 -070065 /**
Andreas Wundsama94273b2013-08-01 22:11:33 -070066 * True if this field is currently logically unspecified in the match, i.e, the
67 * value returned by getValue(f) has no impact on whether a packet will be selected
Yotam Harchol5c9d6f42013-08-01 11:09:20 -070068 * by the match or not.
Andreas Wundsama94273b2013-08-01 22:11:33 -070069 *
Yotam Harchol5c9d6f42013-08-01 11:09:20 -070070 * @param field
71 * @return
72 */
Yotam Harchold7b84202013-07-26 16:08:10 -070073 public boolean isFullyWildcarded(MatchField<?> field);
Andreas Wundsam40e14f72013-05-06 14:49:08 -070074
Yotam Harchol5c9d6f42013-08-01 11:09:20 -070075 /**
Andreas Wundsama94273b2013-08-01 22:11:33 -070076 * True if this field is currently partially specified in the match, i.e, the
Yotam Harchol5c9d6f42013-08-01 11:09:20 -070077 * match will select packets that match (p.value & getMask(field)) == getValue(field).
Andreas Wundsama94273b2013-08-01 22:11:33 -070078 *
Yotam Harchol5c9d6f42013-08-01 11:09:20 -070079 * @param field
80 * @return
81 */
Yotam Harchold7b84202013-07-26 16:08:10 -070082 public boolean isPartiallyMasked(MatchField<?> field);
Andreas Wundsam40e14f72013-05-06 14:49:08 -070083
Yotam Harchol5c9d6f42013-08-01 11:09:20 -070084 /**
85 * Returns a builder to build new instances of this type of match object.
86 * @return Match builder
87 */
Andreas Wundsama94273b2013-08-01 22:11:33 -070088 public MatchBuilder createBuilder();
89
90 interface Builder extends MatchBuilder {
91 }
Andreas Wundsam40e14f72013-05-06 14:49:08 -070092}