blob: 8955e1e47c803f4b4a5a4ae4c48e193be9f20f1e [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:
Andreas Wundsam2fdf99d2013-10-27 06:15:47 -070065 case BSN_IN_PORTS_128:
Yotam Harchol98af7752013-08-22 14:59:38 -070066 return true;
67 default:
68 return false;
69 }
Andreas Wundsambc679f72013-08-01 22:13:09 -070070 }
71
72 @Override
73 public boolean supports(MatchField<?> field) {
Yotam Harchol98af7752013-08-22 14:59:38 -070074 return supportsField(field);
Andreas Wundsambc679f72013-08-01 22:13:09 -070075 }
76
77 @Override
78 public boolean supportsMasked(MatchField<?> field) {
Yotam Harchol98af7752013-08-22 14:59:38 -070079 return supportsField(field);
Andreas Wundsambc679f72013-08-01 22:13:09 -070080 }
81
82 @Override
83 public boolean isExact(MatchField<?> field) {
Yotam Harchol98af7752013-08-22 14:59:38 -070084 if (!supports(field))
85 throw new UnsupportedOperationException("OFMatchV3Ver13 does not support matching on field " + field.getName());
86
87 OFOxm<?> oxm = this.oxmList.get(field);
88
89 return oxm != null && !oxm.isMasked();
Andreas Wundsambc679f72013-08-01 22:13:09 -070090 }
91
92 @Override
93 public boolean isFullyWildcarded(MatchField<?> field) {
Yotam Harchol98af7752013-08-22 14:59:38 -070094 if (!supports(field))
95 throw new UnsupportedOperationException("OFMatchV3Ver13 does not support matching on field " + field.getName());
96
97 OFOxm<?> oxm = this.oxmList.get(field);
98
99 return oxm == null;
Andreas Wundsambc679f72013-08-01 22:13:09 -0700100 }
101
102 @Override
103 public boolean isPartiallyMasked(MatchField<?> field) {
Yotam Harchol98af7752013-08-22 14:59:38 -0700104 if (!supports(field))
105 throw new UnsupportedOperationException("OFMatchV3Ver13 does not support matching on field " + field.getName());
106
107 OFOxm<?> oxm = this.oxmList.get(field);
108
109 return oxm != null && oxm.isMasked();
Andreas Wundsam2fdf99d2013-10-27 06:15:47 -0700110 }