Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 1 | package org.openflow.protocol.match; |
| 2 | |
| 3 | import org.openflow.protocol.OFObject; |
Yotam Harchol | fb4bfb9 | 2013-08-01 14:02:04 -0700 | [diff] [blame] | 4 | import org.openflow.types.Masked; |
Yotam Harchol | d7b8420 | 2013-07-26 16:08:10 -0700 | [diff] [blame] | 5 | import org.openflow.types.OFValueType; |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 6 | |
| 7 | public interface Match extends OFObject { |
Yotam Harchol | 5c9d6f4 | 2013-08-01 11:09:20 -0700 | [diff] [blame] | 8 | |
| 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 Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 29 | |
Yotam Harchol | 5c9d6f4 | 2013-08-01 11:09:20 -0700 | [diff] [blame] | 30 | /** |
Yotam Harchol | fb4bfb9 | 2013-08-01 14:02:04 -0700 | [diff] [blame] | 31 | * 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 Harchol | 5c9d6f4 | 2013-08-01 11:09:20 -0700 | [diff] [blame] | 40 | * Returns true if this match object supports the given match field. |
| 41 | * |
| 42 | * @param field Match field |
| 43 | * @return |
| 44 | */ |
Yotam Harchol | d7b8420 | 2013-07-26 16:08:10 -0700 | [diff] [blame] | 45 | public boolean supports(MatchField<?> field); |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 46 | |
Yotam Harchol | 5c9d6f4 | 2013-08-01 11:09:20 -0700 | [diff] [blame] | 47 | /** |
| 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 Harchol | d7b8420 | 2013-07-26 16:08:10 -0700 | [diff] [blame] | 54 | public boolean supportsMasked(MatchField<?> field); |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 55 | |
Yotam Harchol | 5c9d6f4 | 2013-08-01 11:09:20 -0700 | [diff] [blame] | 56 | /** |
| 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 Harchol | d7b8420 | 2013-07-26 16:08:10 -0700 | [diff] [blame] | 63 | public boolean isExact(MatchField<?> field); |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 64 | |
Yotam Harchol | 5c9d6f4 | 2013-08-01 11:09:20 -0700 | [diff] [blame] | 65 | /** |
| 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 Harchol | d7b8420 | 2013-07-26 16:08:10 -0700 | [diff] [blame] | 73 | public boolean isFullyWildcarded(MatchField<?> field); |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 74 | |
Yotam Harchol | 5c9d6f4 | 2013-08-01 11:09:20 -0700 | [diff] [blame] | 75 | /** |
| 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 Harchol | d7b8420 | 2013-07-26 16:08:10 -0700 | [diff] [blame] | 82 | public boolean isPartiallyMasked(MatchField<?> field); |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 83 | |
Yotam Harchol | 5c9d6f4 | 2013-08-01 11:09:20 -0700 | [diff] [blame] | 84 | /** |
| 85 | * Returns a builder to build new instances of this type of match object. |
| 86 | * @return Match builder |
| 87 | */ |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 88 | public MatchBuilder getBuilder(); |
| 89 | } |