blob: 99b7de4aaba6e3eb5e11ac7d6b02bbc6ba87b9f2 [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 {
Yotam Harchol5c9d6f42013-08-01 11:09:20 -07008
9 /*
10 * Preconditions
11 * On preconditions (from the OF1.1 spec, page 28, the OF1.0 spec failed to explicitly
12 * specify this, but it is the behavior of Of1.0 switches):
13 * 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
19 * and should be set to 0.
20 */
21
22 /**
23 * Returns the value for the given field from this match.
24 *
25 * @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.
33 *
34 * @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.
41 *
42 * @param field Match field
43 * @return
44 */
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 /**
48 * true iff field supports a bitmask mask that wildcards part of the field
49 * (note: not all possible values of this bitmask have to be acceptable)
50 *
51 * @param field Match field
52 * @return
53 */
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 /**
57 * True iff this field is currently fully specified in the match, i.e., the
58 * match will only select packets that match the exact value of getField(field).
59 *
60 * @param field Match field
61 * @return
62 */
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 /**
66 * 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
68 * by the match or not.
69 *
70 * @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 /**
76 * True if this field is currently partially specified in the match, i.e, the
77 * match will select packets that match (p.value & getMask(field)) == getValue(field).
78 *
79 * @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 Wundsam40e14f72013-05-06 14:49:08 -070088 public MatchBuilder getBuilder();
89}