Andreas Wundsam | bc679f7 | 2013-08-01 22:13:09 -0700 | [diff] [blame] | 1 | |
| 2 | @Override |
| 3 | public <F extends OFValueType<F>> F get(MatchField<F> field) |
| 4 | throws UnsupportedOperationException { |
Yotam Harchol | 98af775 | 2013-08-22 14:59:38 -0700 | [diff] [blame] | 5 | if (!supports(field)) |
| 6 | throw new UnsupportedOperationException("OFMatchV3Ver13 does not support matching on field " + field.getName()); |
| 7 | |
| 8 | OFOxm<F> oxm = this.oxmList.get(field); |
| 9 | |
| 10 | if (oxm == null || !field.arePrerequisitesOK(this)) |
| 11 | return null; |
| 12 | |
| 13 | return oxm.getValue(); |
Andreas Wundsam | bc679f7 | 2013-08-01 22:13:09 -0700 | [diff] [blame] | 14 | } |
| 15 | |
| 16 | @Override |
| 17 | public <F extends OFValueType<F>> Masked<F> getMasked(MatchField<F> field) |
| 18 | throws UnsupportedOperationException { |
Yotam Harchol | 98af775 | 2013-08-22 14:59:38 -0700 | [diff] [blame] | 19 | if (!supportsMasked(field)) |
| 20 | throw new UnsupportedOperationException("OFMatchV3Ver13 does not support masked matching on field " + field.getName()); |
| 21 | |
| 22 | OFOxm<F> oxm = this.oxmList.get(field); |
| 23 | |
| 24 | if (oxm == null || !field.arePrerequisitesOK(this)) |
| 25 | return null; |
| 26 | |
| 27 | if (oxm.getMask() == null) |
| 28 | return null; |
| 29 | |
| 30 | // TODO: Make OfOxm extend Masked and just return the OXM? |
| 31 | return Masked.of(oxm.getValue(), oxm.getMask()); |
| 32 | } |
| 33 | |
| 34 | private static boolean supportsField(MatchField<?> field) { |
| 35 | switch (field.id) { |
| 36 | case IN_PORT: |
| 37 | case IN_PHY_PORT: |
| 38 | case METADATA: |
| 39 | case ETH_DST: |
| 40 | case ETH_SRC: |
| 41 | case ETH_TYPE: |
| 42 | case VLAN_VID: |
| 43 | case VLAN_PCP: |
| 44 | case IP_DSCP: |
| 45 | case IP_ECN: |
| 46 | case IP_PROTO: |
| 47 | case IPV4_SRC: |
| 48 | case IPV4_DST: |
| 49 | case TCP_SRC: |
| 50 | case TCP_DST: |
| 51 | case UDP_SRC: |
| 52 | case UDP_DST: |
| 53 | case SCTP_SRC: |
| 54 | case SCTP_DST: |
| 55 | case ICMPV4_TYPE: |
| 56 | case ICMPV4_CODE: |
| 57 | case ARP_OP: |
| 58 | case ARP_SPA: |
| 59 | case ARP_TPA: |
| 60 | case ARP_SHA: |
| 61 | case ARP_THA: |
| 62 | case IPV6_SRC: |
| 63 | case IPV6_DST: |
| 64 | case IPV6_FLABEL: |
| 65 | return true; |
| 66 | default: |
| 67 | return false; |
| 68 | } |
Andreas Wundsam | bc679f7 | 2013-08-01 22:13:09 -0700 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | @Override |
| 72 | public boolean supports(MatchField<?> field) { |
Yotam Harchol | 98af775 | 2013-08-22 14:59:38 -0700 | [diff] [blame] | 73 | return supportsField(field); |
Andreas Wundsam | bc679f7 | 2013-08-01 22:13:09 -0700 | [diff] [blame] | 74 | } |
| 75 | |
| 76 | @Override |
| 77 | public boolean supportsMasked(MatchField<?> field) { |
Yotam Harchol | 98af775 | 2013-08-22 14:59:38 -0700 | [diff] [blame] | 78 | return supportsField(field); |
Andreas Wundsam | bc679f7 | 2013-08-01 22:13:09 -0700 | [diff] [blame] | 79 | } |
| 80 | |
| 81 | @Override |
| 82 | public boolean isExact(MatchField<?> field) { |
Yotam Harchol | 98af775 | 2013-08-22 14:59:38 -0700 | [diff] [blame] | 83 | if (!supports(field)) |
| 84 | throw new UnsupportedOperationException("OFMatchV3Ver13 does not support matching on field " + field.getName()); |
| 85 | |
| 86 | OFOxm<?> oxm = this.oxmList.get(field); |
| 87 | |
| 88 | return oxm != null && !oxm.isMasked(); |
Andreas Wundsam | bc679f7 | 2013-08-01 22:13:09 -0700 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | @Override |
| 92 | public boolean isFullyWildcarded(MatchField<?> field) { |
Yotam Harchol | 98af775 | 2013-08-22 14:59:38 -0700 | [diff] [blame] | 93 | if (!supports(field)) |
| 94 | throw new UnsupportedOperationException("OFMatchV3Ver13 does not support matching on field " + field.getName()); |
| 95 | |
| 96 | OFOxm<?> oxm = this.oxmList.get(field); |
| 97 | |
| 98 | return oxm == null; |
Andreas Wundsam | bc679f7 | 2013-08-01 22:13:09 -0700 | [diff] [blame] | 99 | } |
| 100 | |
| 101 | @Override |
| 102 | public boolean isPartiallyMasked(MatchField<?> field) { |
Yotam Harchol | 98af775 | 2013-08-22 14:59:38 -0700 | [diff] [blame] | 103 | if (!supports(field)) |
| 104 | throw new UnsupportedOperationException("OFMatchV3Ver13 does not support matching on field " + field.getName()); |
| 105 | |
| 106 | OFOxm<?> oxm = this.oxmList.get(field); |
| 107 | |
| 108 | return oxm != null && oxm.isMasked(); |
| 109 | } |