blob: ce6a202b06c56ba1b5b6b61ff6390b5b525cadd3 [file] [log] [blame]
Jonathan Hart23701d12014-04-03 10:45:48 -07001package net.onrc.onos.core.util;
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -08002
3import net.floodlightcontroller.util.MACAddress;
Pavlin Radoslavovad008e02013-02-21 18:42:42 -08004
5import org.codehaus.jackson.annotate.JsonProperty;
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -08006
7/**
8 * The class representing the Flow Entry Matching filter.
Ray Milkey269ffb92014-04-03 14:43:30 -07009 * <p/>
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080010 * The Flow Entry matching filter that is used to specify
11 * the network data that would be forwarded on the data path from
Pavlin Radoslavovede97582013-03-08 18:57:28 -080012 * the source to the destination. Examples: source or destination MAC address,
13 * IP prefix that includes the destination's IP address, etc.
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080014 */
15public class FlowEntryMatch {
Pavlin Radoslavovede97582013-03-08 18:57:28 -080016 /**
17 * A class for storing a value to match.
18 */
Pavlin Radoslavova2d35f12013-10-17 16:46:39 -070019 public static class Field<T> {
Ray Milkey269ffb92014-04-03 14:43:30 -070020 /**
21 * Default constructor.
22 */
23 public Field() {
24 this.enabled = false;
25 }
Pavlin Radoslavovede97582013-03-08 18:57:28 -080026
Ray Milkey269ffb92014-04-03 14:43:30 -070027 /**
28 * Constructor for a given value to match.
29 *
30 * @param value the value to match.
31 */
32 public Field(T value) {
33 this.value = value;
34 this.enabled = true;
35 }
Pavlin Radoslavovede97582013-03-08 18:57:28 -080036
Ray Milkey269ffb92014-04-03 14:43:30 -070037 /**
38 * Get the value.
39 *
40 * @return the value.
41 */
42 public T value() {
43 return this.value;
44 }
Pavlin Radoslavovede97582013-03-08 18:57:28 -080045
Ray Milkey269ffb92014-04-03 14:43:30 -070046 /**
47 * Enable the matching for a given value.
48 *
49 * @param value the value to set.
50 */
51 public void enableMatch(T value) {
52 this.value = value;
53 this.enabled = true;
54 }
Pavlin Radoslavovede97582013-03-08 18:57:28 -080055
Ray Milkey269ffb92014-04-03 14:43:30 -070056 /**
57 * Disable the matching.
58 */
59 public void disableMatch() {
60 this.enabled = false;
61 }
Pavlin Radoslavovede97582013-03-08 18:57:28 -080062
Ray Milkey269ffb92014-04-03 14:43:30 -070063 /**
64 * Test whether matching is enabled.
65 *
66 * @return true if matching is enabled, otherwise false.
67 */
68 public boolean enabled() {
69 return this.enabled;
70 }
Pavlin Radoslavovede97582013-03-08 18:57:28 -080071
Ray Milkey269ffb92014-04-03 14:43:30 -070072 private T value; // The value to match
73 private boolean enabled; // Set to true, if matching is enabled
Pavlin Radoslavovede97582013-03-08 18:57:28 -080074 }
75
Ray Milkey269ffb92014-04-03 14:43:30 -070076 private Field<Port> inPort; // Matching input switch port
77 private Field<MACAddress> srcMac; // Matching source MAC address
78 private Field<MACAddress> dstMac; // Matching destination MAC address
Pavlin Radoslavovad3a1e62013-07-09 13:30:16 -070079 private Field<Short> ethernetFrameType; // Matching Ethernet frame type
Ray Milkey269ffb92014-04-03 14:43:30 -070080 private Field<Short> vlanId; // Matching VLAN ID
81 private Field<Byte> vlanPriority; // Matching VLAN priority
82 private Field<IPv4Net> srcIPv4Net; // Matching source IPv4 prefix
83 private Field<IPv4Net> dstIPv4Net; // Matching destination IPv4 prefix
84 private Field<Byte> ipProto; // Matching IP protocol
85 private Field<Byte> ipToS; // Matching IP ToS (DSCP field, 6 bits)
86 private Field<Short> srcTcpUdpPort; // Matching source TCP/UDP port
87 private Field<Short> dstTcpUdpPort; // Matching destination TCP/UDP port
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080088
89 /**
90 * Default constructor.
91 */
92 public FlowEntryMatch() {
93 }
94
95 /**
Pavlin Radoslavovb9fe6b42013-03-27 16:25:05 -070096 * Copy constructor.
97 *
98 * @param other the object to copy from.
99 */
100 public FlowEntryMatch(FlowEntryMatch other) {
Ray Milkey269ffb92014-04-03 14:43:30 -0700101 if ((other.inPort != null) && other.inPort.enabled())
102 this.enableInPort(other.inPort.value());
103 if ((other.srcMac != null) && other.srcMac.enabled())
104 this.enableSrcMac(other.srcMac.value());
105 if ((other.dstMac != null) && other.dstMac.enabled())
106 this.enableDstMac(other.dstMac.value());
107 if ((other.ethernetFrameType != null) && other.ethernetFrameType.enabled())
108 this.enableEthernetFrameType(other.ethernetFrameType.value());
109 if ((other.vlanId != null) && other.vlanId.enabled())
110 this.enableVlanId(other.vlanId.value());
111 if ((other.vlanPriority != null) && other.vlanPriority.enabled())
112 this.enableVlanPriority(other.vlanPriority.value());
113 if ((other.srcIPv4Net != null) && other.srcIPv4Net.enabled())
114 this.enableSrcIPv4Net(other.srcIPv4Net.value());
115 if ((other.dstIPv4Net != null) && other.dstIPv4Net.enabled())
116 this.enableDstIPv4Net(other.dstIPv4Net.value());
117 if ((other.ipProto != null) && other.ipProto.enabled())
118 this.enableIpProto(other.ipProto.value());
119 if ((other.ipToS != null) && other.ipToS.enabled())
120 this.enableIpToS(other.ipToS.value());
121 if ((other.srcTcpUdpPort != null) && other.srcTcpUdpPort.enabled())
122 this.enableSrcTcpUdpPort(other.srcTcpUdpPort.value());
123 if ((other.dstTcpUdpPort != null) && other.dstTcpUdpPort.enabled())
124 this.enableDstTcpUdpPort(other.dstTcpUdpPort.value());
Pavlin Radoslavovb9fe6b42013-03-27 16:25:05 -0700125 }
126
127 /**
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800128 * Get the matching input switch port.
129 *
130 * @return the matching input switch port.
131 */
132 @JsonProperty("inPort")
133 public Port inPort() {
Ray Milkey269ffb92014-04-03 14:43:30 -0700134 if (inPort != null)
135 return inPort.value();
136 return null;
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800137 }
138
139 /**
140 * Enable the matching on input switch port.
141 *
142 * @param inPort the input switch port value to enable for matching.
143 */
144 @JsonProperty("inPort")
145 public void enableInPort(Port inPort) {
Ray Milkey269ffb92014-04-03 14:43:30 -0700146 this.inPort = new Field<Port>(inPort);
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800147 }
148
149 /**
150 * Disable the matching on input switch port.
151 */
152 public void disableInPort() {
Ray Milkey269ffb92014-04-03 14:43:30 -0700153 this.inPort = null;
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800154 }
155
156 /**
157 * Test if matching on input switch port is enabled.
158 *
159 * @return true if matching on input switch port is enabled.
160 */
161 @JsonProperty("matchInPort")
162 public boolean matchInPort() {
Ray Milkey269ffb92014-04-03 14:43:30 -0700163 if (inPort != null)
164 return inPort.enabled();
165 return false;
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800166 }
167
168 /**
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800169 * Get the matching source MAC address.
170 *
171 * @return the matching source MAC address.
172 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -0800173 @JsonProperty("srcMac")
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800174 public MACAddress srcMac() {
Ray Milkey269ffb92014-04-03 14:43:30 -0700175 if (srcMac != null)
176 return srcMac.value();
177 return null;
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800178 }
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800179
180 /**
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800181 * Enable the matching on source MAC address.
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800182 *
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800183 * @param srcMac the source MAC address value to enable for matching.
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800184 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -0800185 @JsonProperty("srcMac")
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800186 public void enableSrcMac(MACAddress srcMac) {
Ray Milkey269ffb92014-04-03 14:43:30 -0700187 this.srcMac = new Field<MACAddress>(srcMac);
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800188 }
189
190 /**
191 * Disable the matching on source MAC address.
192 */
193 public void disableSrcMac() {
Ray Milkey269ffb92014-04-03 14:43:30 -0700194 this.srcMac = null;
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800195 }
196
197 /**
198 * Test if matching on source MAC address is enabled.
199 *
200 * @return true if matching on source MAC address is enabled.
201 */
202 @JsonProperty("matchSrcMac")
203 public boolean matchSrcMac() {
Ray Milkey269ffb92014-04-03 14:43:30 -0700204 if (srcMac != null)
205 return srcMac.enabled();
206 return false;
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800207 }
208
209 /**
210 * Get the matching destination MAC address.
211 *
212 * @return the matching destination MAC address.
213 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -0800214 @JsonProperty("dstMac")
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800215 public MACAddress dstMac() {
Ray Milkey269ffb92014-04-03 14:43:30 -0700216 if (dstMac != null)
217 return dstMac.value();
218 return null;
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800219 }
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800220
221 /**
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800222 * Enable the matching on destination MAC address.
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800223 *
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800224 * @param dstMac the destination MAC address value to enable for matching.
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800225 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -0800226 @JsonProperty("dstMac")
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800227 public void enableDstMac(MACAddress dstMac) {
Ray Milkey269ffb92014-04-03 14:43:30 -0700228 this.dstMac = new Field<MACAddress>(dstMac);
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800229 }
230
231 /**
232 * Disable the matching on destination MAC address.
233 */
234 public void disableDstMac() {
Ray Milkey269ffb92014-04-03 14:43:30 -0700235 this.dstMac = null;
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800236 }
237
238 /**
239 * Test if matching on destination MAC address is enabled.
240 *
241 * @return true if matching on destination MAC address is enabled.
242 */
243 @JsonProperty("matchDstMac")
244 public boolean matchDstMac() {
Ray Milkey269ffb92014-04-03 14:43:30 -0700245 if (dstMac != null)
246 return dstMac.enabled();
247 return false;
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800248 }
249
250 /**
Pavlin Radoslavovad3a1e62013-07-09 13:30:16 -0700251 * Get the matching Ethernet frame type.
252 *
253 * @return the matching Ethernet frame type.
254 */
255 @JsonProperty("ethernetFrameType")
256 public Short ethernetFrameType() {
Ray Milkey269ffb92014-04-03 14:43:30 -0700257 if (ethernetFrameType != null)
258 return ethernetFrameType.value();
259 return null;
Pavlin Radoslavovad3a1e62013-07-09 13:30:16 -0700260 }
261
262 /**
263 * Enable the matching on Ethernet frame type.
264 *
265 * @param ethernetFrameType the Ethernet frame type value to enable for
Ray Milkey269ffb92014-04-03 14:43:30 -0700266 * matching.
Pavlin Radoslavovad3a1e62013-07-09 13:30:16 -0700267 */
268 @JsonProperty("ethernetFrameType")
269 public void enableEthernetFrameType(Short ethernetFrameType) {
Ray Milkey269ffb92014-04-03 14:43:30 -0700270 this.ethernetFrameType = new Field<Short>(ethernetFrameType);
Pavlin Radoslavovad3a1e62013-07-09 13:30:16 -0700271 }
272
273 /**
274 * Disable the matching on Ethernet frame type.
275 */
276 public void disableEthernetFrameType() {
Ray Milkey269ffb92014-04-03 14:43:30 -0700277 this.ethernetFrameType = null;
Pavlin Radoslavovad3a1e62013-07-09 13:30:16 -0700278 }
279
280 /**
281 * Test if matching on Ethernet frame type is enabled.
282 *
283 * @return true if matching on Ethernet frame type is enabled.
284 */
285 @JsonProperty("matchEthernetFrameType")
286 public boolean matchEthernetFrameType() {
Ray Milkey269ffb92014-04-03 14:43:30 -0700287 if (ethernetFrameType != null)
288 return ethernetFrameType.enabled();
289 return false;
Pavlin Radoslavovad3a1e62013-07-09 13:30:16 -0700290 }
291
292 /**
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800293 * Get the matching VLAN ID.
294 *
295 * @return the matching VLAN ID.
296 */
297 @JsonProperty("vlanId")
298 public Short vlanId() {
Ray Milkey269ffb92014-04-03 14:43:30 -0700299 if (vlanId != null)
300 return vlanId.value();
301 return null;
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800302 }
303
304 /**
305 * Enable the matching on VLAN ID.
306 *
307 * @param vlanId the VLAN ID value to enable for matching.
308 */
309 @JsonProperty("vlanId")
310 public void enableVlanId(Short vlanId) {
Ray Milkey269ffb92014-04-03 14:43:30 -0700311 this.vlanId = new Field<Short>(vlanId);
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800312 }
313
314 /**
315 * Disable the matching on VLAN ID.
316 */
317 public void disableVlanId() {
Ray Milkey269ffb92014-04-03 14:43:30 -0700318 this.vlanId = null;
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800319 }
320
321 /**
322 * Test if matching on VLAN ID is enabled.
323 *
324 * @return true if matching on VLAN ID is enabled.
325 */
326 @JsonProperty("matchVlanId")
327 public boolean matchVlanId() {
Ray Milkey269ffb92014-04-03 14:43:30 -0700328 if (vlanId != null)
329 return vlanId.enabled();
330 return false;
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800331 }
332
333 /**
334 * Get the matching VLAN priority.
335 *
336 * @return the matching VLAN priority.
337 */
338 @JsonProperty("vlanPriority")
339 public Byte vlanPriority() {
Ray Milkey269ffb92014-04-03 14:43:30 -0700340 if (vlanPriority != null)
341 return vlanPriority.value();
342 return null;
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800343 }
344
345 /**
346 * Enable the matching on VLAN priority.
347 *
348 * @param vlanPriority the VLAN priority value to enable for matching.
349 */
350 @JsonProperty("vlanPriority")
351 public void enableVlanPriority(Byte vlanPriority) {
Ray Milkey269ffb92014-04-03 14:43:30 -0700352 this.vlanPriority = new Field<Byte>(vlanPriority);
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800353 }
354
355 /**
356 * Disable the matching on VLAN priority.
357 */
358 public void disableVlanPriority() {
Ray Milkey269ffb92014-04-03 14:43:30 -0700359 this.vlanPriority = null;
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800360 }
361
362 /**
363 * Test if matching on VLAN priority is enabled.
364 *
365 * @return true if matching on VLAN priority is enabled.
366 */
367 @JsonProperty("matchVlanPriority")
368 public boolean matchVlanPriority() {
Ray Milkey269ffb92014-04-03 14:43:30 -0700369 if (vlanPriority != null)
370 return vlanPriority.enabled();
371 return false;
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800372 }
373
374 /**
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800375 * Get the matching source IPv4 prefix.
376 *
377 * @return the matching source IPv4 prefix.
378 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -0800379 @JsonProperty("srcIPv4Net")
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800380 public IPv4Net srcIPv4Net() {
Ray Milkey269ffb92014-04-03 14:43:30 -0700381 if (srcIPv4Net != null)
382 return srcIPv4Net.value();
383 return null;
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800384 }
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800385
386 /**
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800387 * Enable the matching on source IPv4 prefix.
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800388 *
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800389 * @param srcIPv4Net the source IPv4 prefix value to enable for matching.
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800390 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -0800391 @JsonProperty("srcIPv4Net")
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800392 public void enableSrcIPv4Net(IPv4Net srcIPv4Net) {
Ray Milkey269ffb92014-04-03 14:43:30 -0700393 this.srcIPv4Net = new Field<IPv4Net>(srcIPv4Net);
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800394 }
395
396 /**
397 * Disable the matching on source IPv4 prefix.
398 */
399 public void disableSrcIPv4Net() {
Ray Milkey269ffb92014-04-03 14:43:30 -0700400 this.srcIPv4Net = null;
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800401 }
402
403 /**
404 * Test if matching on source IPv4 prefix is enabled.
405 *
406 * @return true if matching on source IPv4 prefix is enabled.
407 */
408 @JsonProperty("matchSrcIPv4Net")
409 public boolean matchSrcIPv4Net() {
Ray Milkey269ffb92014-04-03 14:43:30 -0700410 if (srcIPv4Net != null)
411 return srcIPv4Net.enabled();
412 return false;
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800413 }
414
415 /**
416 * Get the matching destination IPv4 prefix.
417 *
418 * @return the matching destination IPv4 prefix.
419 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -0800420 @JsonProperty("dstIPv4Net")
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800421 public IPv4Net dstIPv4Net() {
Ray Milkey269ffb92014-04-03 14:43:30 -0700422 if (dstIPv4Net != null)
423 return dstIPv4Net.value();
424 return null;
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800425 }
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800426
427 /**
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800428 * Enable the matching on destination IPv4 prefix.
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800429 *
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800430 * @param dstIPv4Net the destination IPv4 prefix value to enable for
Ray Milkey269ffb92014-04-03 14:43:30 -0700431 * matching.
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800432 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -0800433 @JsonProperty("dstIPv4Net")
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800434 public void enableDstIPv4Net(IPv4Net dstIPv4Net) {
Ray Milkey269ffb92014-04-03 14:43:30 -0700435 this.dstIPv4Net = new Field<IPv4Net>(dstIPv4Net);
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800436 }
437
438 /**
439 * Disable the matching on destination IPv4 prefix.
440 */
441 public void disableDstIPv4Net() {
Ray Milkey269ffb92014-04-03 14:43:30 -0700442 this.dstIPv4Net = null;
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800443 }
444
445 /**
446 * Test if matching on destination IPv4 prefix is enabled.
447 *
448 * @return true if matching on destination IPv4 prefix is enabled.
449 */
450 @JsonProperty("matchDstIPv4Net")
451 public boolean matchDstIPv4Net() {
Ray Milkey269ffb92014-04-03 14:43:30 -0700452 if (dstIPv4Net != null)
453 return dstIPv4Net.enabled();
454 return false;
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800455 }
456
457 /**
Pavlin Radoslavovad3a1e62013-07-09 13:30:16 -0700458 * Get the matching IP protocol.
459 *
460 * @return the matching IP protocol.
461 */
462 @JsonProperty("ipProto")
463 public Byte ipProto() {
Ray Milkey269ffb92014-04-03 14:43:30 -0700464 if (ipProto != null)
465 return ipProto.value();
466 return null;
Pavlin Radoslavovad3a1e62013-07-09 13:30:16 -0700467 }
468
469 /**
470 * Enable the matching on IP protocol.
471 *
472 * @param ipProto the IP protocol value to enable for matching.
473 */
474 @JsonProperty("ipProto")
475 public void enableIpProto(Byte ipProto) {
Ray Milkey269ffb92014-04-03 14:43:30 -0700476 this.ipProto = new Field<Byte>(ipProto);
Pavlin Radoslavovad3a1e62013-07-09 13:30:16 -0700477 }
478
479 /**
480 * Disable the matching on IP protocol.
481 */
482 public void disableIpProto() {
Ray Milkey269ffb92014-04-03 14:43:30 -0700483 this.ipProto = null;
Pavlin Radoslavovad3a1e62013-07-09 13:30:16 -0700484 }
485
486 /**
487 * Test if matching on IP protocol is enabled.
488 *
489 * @return true if matching on IP protocol is enabled.
490 */
491 @JsonProperty("matchIpProto")
492 public boolean matchIpProto() {
Ray Milkey269ffb92014-04-03 14:43:30 -0700493 if (ipProto != null)
494 return ipProto.enabled();
495 return false;
Pavlin Radoslavovad3a1e62013-07-09 13:30:16 -0700496 }
497
498 /**
499 * Get the matching IP ToS (DSCP field, 6 bits)
500 *
501 * @return the matching IP ToS.
502 */
503 @JsonProperty("ipToS")
504 public Byte ipToS() {
Ray Milkey269ffb92014-04-03 14:43:30 -0700505 if (ipToS != null)
506 return ipToS.value();
507 return null;
Pavlin Radoslavovad3a1e62013-07-09 13:30:16 -0700508 }
509
510 /**
511 * Enable the matching on IP ToS (DSCP field, 6 bits).
512 *
513 * @param ipToS the IP ToS value to enable for matching.
514 */
515 @JsonProperty("ipToS")
516 public void enableIpToS(Byte ipToS) {
Ray Milkey269ffb92014-04-03 14:43:30 -0700517 this.ipToS = new Field<Byte>(ipToS);
Pavlin Radoslavovad3a1e62013-07-09 13:30:16 -0700518 }
519
520 /**
521 * Disable the matching on IP ToS (DSCP field, 6 bits).
522 */
523 public void disableIpToS() {
Ray Milkey269ffb92014-04-03 14:43:30 -0700524 this.ipToS = null;
Pavlin Radoslavovad3a1e62013-07-09 13:30:16 -0700525 }
526
527 /**
528 * Test if matching on IP ToS (DSCP field, 6 bits) is enabled.
529 *
530 * @return true if matching on IP ToS is enabled.
531 */
532 @JsonProperty("matchIpToS")
533 public boolean matchIpToS() {
Ray Milkey269ffb92014-04-03 14:43:30 -0700534 if (ipToS != null)
535 return ipToS.enabled();
536 return false;
Pavlin Radoslavovad3a1e62013-07-09 13:30:16 -0700537 }
538
539 /**
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800540 * Get the matching source TCP/UDP port.
541 *
542 * @return the matching source TCP/UDP port.
543 */
544 @JsonProperty("srcTcpUdpPort")
545 public Short srcTcpUdpPort() {
Ray Milkey269ffb92014-04-03 14:43:30 -0700546 if (srcTcpUdpPort != null)
547 return srcTcpUdpPort.value();
548 return null;
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800549 }
550
551 /**
552 * Enable the matching on source TCP/UDP port.
553 *
554 * @param srcTcpUdpPort the source TCP/UDP port to enable for matching.
555 */
556 @JsonProperty("srcTcpUdpPort")
557 public void enableSrcTcpUdpPort(Short srcTcpUdpPort) {
Ray Milkey269ffb92014-04-03 14:43:30 -0700558 this.srcTcpUdpPort = new Field<Short>(srcTcpUdpPort);
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800559 }
560
561 /**
562 * Disable the matching on source TCP/UDP port.
563 */
564 public void disableSrcTcpUdpPort() {
Ray Milkey269ffb92014-04-03 14:43:30 -0700565 this.srcTcpUdpPort = null;
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800566 }
567
568 /**
569 * Test if matching on source TCP/UDP port is enabled.
570 *
571 * @return true if matching on source TCP/UDP port is enabled.
572 */
573 @JsonProperty("matchSrcTcpUdpPort")
574 public boolean matchSrcTcpUdpPort() {
Ray Milkey269ffb92014-04-03 14:43:30 -0700575 if (srcTcpUdpPort != null)
576 return srcTcpUdpPort.enabled();
577 return false;
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800578 }
579
580 /**
581 * Get the matching destination TCP/UDP port.
582 *
583 * @return the matching destination TCP/UDP port.
584 */
585 @JsonProperty("dstTcpUdpPort")
586 public Short dstTcpUdpPort() {
Ray Milkey269ffb92014-04-03 14:43:30 -0700587 if (dstTcpUdpPort != null)
588 return dstTcpUdpPort.value();
589 return null;
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800590 }
591
592 /**
593 * Enable the matching on destination TCP/UDP port.
594 *
595 * @param dstTcpUdpPort the destination TCP/UDP port to enable for
Ray Milkey269ffb92014-04-03 14:43:30 -0700596 * matching.
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800597 */
598 @JsonProperty("dstTcpUdpPort")
599 public void enableDstTcpUdpPort(Short dstTcpUdpPort) {
Ray Milkey269ffb92014-04-03 14:43:30 -0700600 this.dstTcpUdpPort = new Field<Short>(dstTcpUdpPort);
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800601 }
602
603 /**
604 * Disable the matching on destination TCP/UDP port.
605 */
606 public void disableDstTcpUdpPort() {
Ray Milkey269ffb92014-04-03 14:43:30 -0700607 this.dstTcpUdpPort = null;
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800608 }
609
610 /**
611 * Test if matching on destination TCP/UDP port is enabled.
612 *
613 * @return true if matching on destination TCP/UDP port is enabled.
614 */
615 @JsonProperty("matchDstTcpUdpPort")
616 public boolean matchDstTcpUdpPort() {
Ray Milkey269ffb92014-04-03 14:43:30 -0700617 if (dstTcpUdpPort != null)
618 return dstTcpUdpPort.enabled();
619 return false;
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800620 }
621
622 /**
623 * Convert the matching filter to a string.
Ray Milkey269ffb92014-04-03 14:43:30 -0700624 * <p/>
Pavlin Radoslavovad008e02013-02-21 18:42:42 -0800625 * The string has the following form:
Ray Milkey269ffb92014-04-03 14:43:30 -0700626 * [srcMac=XXX dstMac=XXX srcIPv4Net=XXX dstIPv4Net=XXX]
Pavlin Radoslavovad008e02013-02-21 18:42:42 -0800627 *
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800628 * @return the matching filter as a string.
629 */
630 @Override
631 public String toString() {
Ray Milkey269ffb92014-04-03 14:43:30 -0700632 String ret = "[";
633 boolean addSpace = false;
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800634
Ray Milkey269ffb92014-04-03 14:43:30 -0700635 //
636 // Conditionally add only those matching fields that are enabled
637 //
638 if (matchInPort()) {
639 if (addSpace)
640 ret += " ";
641 addSpace = true;
642 ret += "inPort=" + this.inPort().toString();
643 }
644 if (matchSrcMac()) {
645 if (addSpace)
646 ret += " ";
647 addSpace = true;
648 ret += "srcMac=" + this.srcMac().toString();
649 }
650 if (matchDstMac()) {
651 if (addSpace)
652 ret += " ";
653 addSpace = true;
654 ret += "dstMac=" + this.dstMac().toString();
655 }
656 if (matchEthernetFrameType()) {
657 if (addSpace)
658 ret += " ";
659 addSpace = true;
660 ret += "ethernetFrameType=" + this.ethernetFrameType().toString();
661 }
662 if (matchVlanId()) {
663 if (addSpace)
664 ret += " ";
665 addSpace = true;
666 ret += "vlanId=" + this.vlanId().toString();
667 }
668 if (matchVlanPriority()) {
669 if (addSpace)
670 ret += " ";
671 addSpace = true;
672 ret += "vlanPriority=" + this.vlanPriority().toString();
673 }
674 if (matchSrcIPv4Net()) {
675 if (addSpace)
676 ret += " ";
677 addSpace = true;
678 ret += "srcIPv4Net=" + this.srcIPv4Net().toString();
679 }
680 if (matchDstIPv4Net()) {
681 if (addSpace)
682 ret += " ";
683 addSpace = true;
684 ret += "dstIPv4Net=" + this.dstIPv4Net().toString();
685 }
686 if (matchIpProto()) {
687 if (addSpace)
688 ret += " ";
689 addSpace = true;
690 ret += "ipProto=" + this.ipProto().toString();
691 }
692 if (matchIpToS()) {
693 if (addSpace)
694 ret += " ";
695 addSpace = true;
696 ret += "ipToS=" + this.ipToS().toString();
697 }
698 if (matchSrcTcpUdpPort()) {
699 if (addSpace)
700 ret += " ";
701 addSpace = true;
702 ret += "srcTcpUdpPort=" + this.srcTcpUdpPort().toString();
703 }
704 if (matchDstTcpUdpPort()) {
705 if (addSpace)
706 ret += " ";
707 addSpace = true;
708 ret += "dstTcpUdpPort=" + this.dstTcpUdpPort().toString();
709 }
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800710
Ray Milkey269ffb92014-04-03 14:43:30 -0700711 ret += "]";
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800712
Ray Milkey269ffb92014-04-03 14:43:30 -0700713 return ret;
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800714 }
715}