blob: a4cc51c77ba9795aa26c248d576402e26d612887 [file] [log] [blame]
Andreas Wundsambc679f72013-08-01 22:13:09 -07001
2 @Override
3 public <F extends OFValueType<F>> F get(MatchField<F> field)
4 throws UnsupportedOperationException {
Yotam Harchol98af7752013-08-22 14:59:38 -07005 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 Wundsambc679f72013-08-01 22:13:09 -070014 }
15
16 @Override
17 public <F extends OFValueType<F>> Masked<F> getMasked(MatchField<F> field)
18 throws UnsupportedOperationException {
Yotam Harchol98af7752013-08-22 14:59:38 -070019 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 Wundsambc679f72013-08-01 22:13:09 -070069 }
70
71 @Override
72 public boolean supports(MatchField<?> field) {
Yotam Harchol98af7752013-08-22 14:59:38 -070073 return supportsField(field);
Andreas Wundsambc679f72013-08-01 22:13:09 -070074 }
75
76 @Override
77 public boolean supportsMasked(MatchField<?> field) {
Yotam Harchol98af7752013-08-22 14:59:38 -070078 return supportsField(field);
Andreas Wundsambc679f72013-08-01 22:13:09 -070079 }
80
81 @Override
82 public boolean isExact(MatchField<?> field) {
Yotam Harchol98af7752013-08-22 14:59:38 -070083 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 Wundsambc679f72013-08-01 22:13:09 -070089 }
90
91 @Override
92 public boolean isFullyWildcarded(MatchField<?> field) {
Yotam Harchol98af7752013-08-22 14:59:38 -070093 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 Wundsambc679f72013-08-01 22:13:09 -070099 }
100
101 @Override
102 public boolean isPartiallyMasked(MatchField<?> field) {
Yotam Harchol98af7752013-08-22 14:59:38 -0700103 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 }