blob: 858272c041af164782e5552a604ebc43dba683b5 [file] [log] [blame]
HIGUCHI Yuta356086e2013-06-12 15:21:19 -07001package net.onrc.onos.ofcontroller.util;
Pavlin Radoslavovede97582013-03-08 18:57:28 -08002
Pavlin Radoslavovede97582013-03-08 18:57:28 -08003import net.floodlightcontroller.util.MACAddress;
HIGUCHI Yuta356086e2013-06-12 15:21:19 -07004import net.onrc.onos.ofcontroller.util.Port.PortValues;
Pavlin Radoslavovede97582013-03-08 18:57:28 -08005
6import org.codehaus.jackson.annotate.JsonProperty;
7
8/**
9 * The class representing a single Flow Entry action.
10 *
11 * A set of Flow Entry actions need to be applied to each packet.
12 */
13public class FlowEntryAction {
14 /**
15 * Special action values.
16 *
17 * Those values are taken as-is from the OpenFlow-v1.0.0 specification
18 * (pp 21-22).
19 */
20 public enum ActionValues {
21 ACTION_OUTPUT ((short)0x0), // Output to switch port
22 ACTION_SET_VLAN_VID ((short)0x1), // Set the 802.1q VLAN id
23 ACTION_SET_VLAN_PCP ((short)0x2), // Set the 802.1q priority
24 ACTION_STRIP_VLAN ((short)0x3), // Strip the 802.1q header
25 ACTION_SET_DL_SRC ((short)0x4), // Ethernet source address
26 ACTION_SET_DL_DST ((short)0x5), // Ethernet destination address
27 ACTION_SET_NW_SRC ((short)0x6), // IP source address
28 ACTION_SET_NW_DST ((short)0x7), // IP destination address
29 ACTION_SET_NW_TOS ((short)0x8), // IP ToS (DSCP field, 6 bits)
30 ACTION_SET_TP_SRC ((short)0x9), // TCP/UDP source port
31 ACTION_SET_TP_DST ((short)0xa), // TCP/UDP destination port
32 ACTION_ENQUEUE ((short)0xb), // Output to queue on port
33 ACTION_VENDOR ((short)0xffff); // Vendor-specific
34
35 private final short value; // The value
36
37 /**
38 * Constructor for a given value.
39 *
40 * @param value the value to use for the initialization.
41 */
42 private ActionValues(short value) {
43 this.value = value;
44 }
45 }
46
47 /**
48 * Action structure for ACTION_OUTPUT: Output to switch port.
49 */
50 public class ActionOutput {
51 private Port port; // Output port
52 private short maxLen; // Max. length (in bytes) to send to controller
53 // if the port is set to PORT_CONTROLLER
54
55 /**
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -070056 * Default constructor.
57 */
58 public ActionOutput() {
59 this.port = null;
60 this.maxLen = 0;
61 }
62
63
64 /**
Pavlin Radoslavovede97582013-03-08 18:57:28 -080065 * Constructor for a given output port and maximum length.
66 *
67 * @param port the output port to set.
68 * @param maxLen the maximum length (in bytes) to send to controller
69 * if the port is set to PORT_CONTROLLER.
70 */
71 public ActionOutput(Port port, short maxLen) {
72 this.port = port;
73 this.maxLen = maxLen;
74 }
75
76 /**
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -070077 * Constructor for a given output port.
78 *
79 * @param port the output port to set.
80 */
81 public ActionOutput(Port port) {
82 this.port = port;
83 this.maxLen = 0;
84 }
85
86 /**
Pavlin Radoslavovede97582013-03-08 18:57:28 -080087 * Get the output port.
88 *
89 * @return the output port.
90 */
91 @JsonProperty("port")
92 public Port port() {
93 return this.port;
94 }
95
96 /**
97 * Get the maximum length (in bytes) to send to controller if the
98 * port is set to PORT_CONTROLLER.
99 *
100 * @return the maximum length (in bytes) to send to controller if the
101 * port is set to PORT_CONTROLLER.
102 */
103 @JsonProperty("maxLen")
104 public short maxLen() {
105 return this.maxLen;
106 }
107
108 /**
109 * Convert the action to a string.
110 *
111 * The string has the following form:
112 * [port=XXX maxLen=XXX]
113 *
114 * @return the action as a string.
115 */
116 @Override
117 public String toString() {
118 String ret = "[";
119 ret += "port=" + port.toString();
120 ret += " maxLen=" + maxLen;
121 ret += "]";
122
123 return ret;
124 }
125 }
126
127 /**
128 * Action structure for ACTION_SET_VLAN_VID: Set the 802.1q VLAN id
129 */
130 public class ActionSetVlanId {
131 private short vlanId; // The VLAN ID to set
132
133 /**
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700134 * Default constructor.
135 */
136 public ActionSetVlanId() {
137 this.vlanId = 0;
138 }
139
140 /**
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800141 * Constructor for a given VLAN ID.
142 *
143 * @param vlanId the VLAN ID to set.
144 */
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700145 public ActionSetVlanId(short vlanId) {
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800146 this.vlanId = vlanId;
147 }
148
149 /**
150 * Get the VLAN ID.
151 *
152 * @return the VLAN ID.
153 */
154 @JsonProperty("vlanId")
155 public short vlanId() {
156 return this.vlanId;
157 }
158
159 /**
160 * Convert the action to a string.
161 *
162 * The string has the following form:
163 * [vlanId=XXX]
164 *
165 * @return the action as a string.
166 */
167 @Override
168 public String toString() {
169 String ret = "[";
170 ret += "vlanId=" + this.vlanId;
171 ret += "]";
172
173 return ret;
174 }
175 }
176
177 /**
178 * Action structure for ACTION_SET_VLAN_PCP: Set the 802.1q priority
179 */
180 public class ActionSetVlanPriority {
181 private byte vlanPriority; // The VLAN priority to set
182
183 /**
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700184 * Default constructor.
185 */
186 public ActionSetVlanPriority() {
187 this.vlanPriority = 0;
188 }
189
190 /**
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800191 * Constructor for a given VLAN priority.
192 *
193 * @param vlanPriority the VLAN priority to set.
194 */
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700195 public ActionSetVlanPriority(byte vlanPriority) {
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800196 this.vlanPriority = vlanPriority;
197 }
198
199 /**
200 * Get the VLAN priority.
201 *
202 * @return the VLAN priority.
203 */
204 @JsonProperty("vlanPriority")
205 public byte vlanPriority() {
206 return this.vlanPriority;
207 }
208
209 /**
210 * Convert the action to a string.
211 *
212 * The string has the following form:
213 * [vlanPriority=XXX]
214 *
215 * @return the action as a string.
216 */
217 @Override
218 public String toString() {
219 String ret = "[";
220 ret += "vlanPriority=" + this.vlanPriority;
221 ret += "]";
222
223 return ret;
224 }
225 }
226
227 /**
228 * Action structure for ACTION_STRIP_VLAN: Strip the 802.1q header
229 */
230 public class ActionStripVlan {
231 private boolean stripVlan; // If true, strip the VLAN header
232
233 /**
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700234 * Default constructor.
235 */
236 public ActionStripVlan() {
237 this.stripVlan = false;
238 }
239
240 /**
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800241 * Constructor for a given boolean flag.
242 *
243 * @param stripVlan if true, strip the VLAN header.
244 */
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700245 public ActionStripVlan(boolean stripVlan) {
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800246 this.stripVlan = stripVlan;
247 }
248
249 /**
250 * Get the boolean flag whether the VLAN header should be stripped.
251 *
252 * @return the boolean flag whether the VLAN header should be stripped.
253 */
254 @JsonProperty("stripVlan")
255 public boolean stripVlan() {
256 return this.stripVlan;
257 }
258
259 /**
260 * Convert the action to a string.
261 *
262 * The string has the following form:
263 * [stripVlan=XXX]
264 *
265 * @return the action as a string.
266 */
267 @Override
268 public String toString() {
269 String ret = "[";
270 ret += "stripVlan=" + this.stripVlan;
271 ret += "]";
272
273 return ret;
274 }
275 }
276
277 /**
278 * Action structure for ACTION_SET_DL_SRC and ACTION_SET_DL_DST:
279 * Set the Ethernet source/destination address.
280 */
281 public class ActionSetEthernetAddr {
282 private MACAddress addr; // The MAC address to set
283
284 /**
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700285 * Default constructor.
286 */
287 public ActionSetEthernetAddr() {
288 this.addr = null;
289 }
290
291 /**
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800292 * Constructor for a given MAC address.
293 *
294 * @param addr the MAC address to set.
295 */
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700296 public ActionSetEthernetAddr(MACAddress addr) {
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800297 this.addr = addr;
298 }
299
300 /**
301 * Get the MAC address.
302 *
303 * @return the MAC address.
304 */
305 @JsonProperty("addr")
306 public MACAddress addr() {
307 return this.addr;
308 }
309
310 /**
311 * Convert the action to a string.
312 *
313 * The string has the following form:
314 * [addr=XXX]
315 *
316 * @return the action as a string.
317 */
318 @Override
319 public String toString() {
320 String ret = "[";
321 ret += "addr=" + addr.toString();
322 ret += "]";
323
324 return ret;
325 }
326 }
327
328 /**
329 * Action structure for ACTION_SET_NW_SRC and ACTION_SET_NW_DST:
330 * Set the IPv4 source/destination address.
331 */
332 public class ActionSetIPv4Addr {
333 private IPv4 addr; // The IPv4 address to set
334
335 /**
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700336 * Default constructor.
337 */
338 public ActionSetIPv4Addr() {
339 this.addr = null;
340 }
341
342 /**
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800343 * Constructor for a given IPv4 address.
344 *
345 * @param addr the IPv4 address to set.
346 */
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700347 public ActionSetIPv4Addr(IPv4 addr) {
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800348 this.addr = addr;
349 }
350
351 /**
352 * Get the IPv4 address.
353 *
354 * @return the IPv4 address.
355 */
356 @JsonProperty("addr")
357 public IPv4 addr() {
358 return this.addr;
359 }
360
361 /**
362 * Convert the action to a string.
363 *
364 * The string has the following form:
365 * [addr=XXX]
366 *
367 * @return the action as a string.
368 */
369 @Override
370 public String toString() {
371 String ret = "[";
372 ret += "addr=" + addr.toString();
373 ret += "]";
374
375 return ret;
376 }
377 }
378
379 /**
380 * Action structure for ACTION_SET_NW_TOS:
381 * Set the IP ToS (DSCP field, 6 bits).
382 */
383 public class ActionSetIpToS {
384 private byte ipToS; // The IP ToS to set DSCP field, 6 bits)
385
386 /**
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700387 * Default constructor.
388 */
389 public ActionSetIpToS() {
390 this.ipToS = 0;
391 }
392
393 /**
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800394 * Constructor for a given IP ToS (DSCP field, 6 bits).
395 *
396 * @param ipToS the IP ToS (DSCP field, 6 bits) to set.
397 */
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700398 public ActionSetIpToS(byte ipToS) {
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800399 this.ipToS = ipToS;
400 }
401
402 /**
403 * Get the IP ToS (DSCP field, 6 bits).
404 *
405 * @return the IP ToS (DSCP field, 6 bits).
406 */
407 @JsonProperty("ipToS")
408 public byte ipToS() {
409 return this.ipToS;
410 }
411
412 /**
413 * Convert the action to a string.
414 *
415 * The string has the following form:
416 * [ipToS=XXX]
417 *
418 * @return the action as a string.
419 */
420 @Override
421 public String toString() {
422 String ret = "[";
423 ret += "ipToS=" + ipToS;
424 ret += "]";
425
426 return ret;
427 }
428 }
429
430 /**
431 * Action structure for ACTION_SET_TP_SRC and ACTION_SET_TP_DST:
432 * Set the TCP/UDP source/destination port.
433 */
434 public class ActionSetTcpUdpPort {
435 private short port; // The TCP/UDP port to set
436
437 /**
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700438 * Default constructor.
439 */
440 public ActionSetTcpUdpPort() {
441 this.port = 0;
442 }
443
444 /**
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800445 * Constructor for a given TCP/UDP port.
446 *
447 * @param port the TCP/UDP port to set.
448 */
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700449 public ActionSetTcpUdpPort(short port) {
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800450 this.port = port;
451 }
452
453 /**
454 * Get the TCP/UDP port.
455 *
456 * @return the TCP/UDP port.
457 */
458 @JsonProperty("port")
459 public short port() {
460 return this.port;
461 }
462
463 /**
464 * Convert the action to a string.
465 *
466 * The string has the following form:
467 * [port=XXX]
468 *
469 * @return the action as a string.
470 */
471 @Override
472 public String toString() {
473 String ret = "[";
474 ret += "port=" + port;
475 ret += "]";
476
477 return ret;
478 }
479 }
480
481 /**
482 * Action structure for ACTION_ENQUEUE: Output to queue on port.
483 */
484 public class ActionEnqueue {
485 private Port port; // Port that queue belongs. Should
486 // refer to a valid physical port
487 // (i.e. < PORT_MAX) or PORT_IN_PORT
488 private int queueId; // Where to enqueue the packets
489
490 /**
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700491 * Default constructor.
492 */
493 public ActionEnqueue() {
494 this.port = null;
495 this.queueId = 0;
496 }
497
498 /**
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800499 * Constructor for a given port and queue ID.
500 *
501 * @param port the port to set.
502 * @param queueId the queue ID on the port.
503 */
504 public ActionEnqueue(Port port, int queueId) {
505 this.port = port;
506 this.queueId = queueId;
507 }
508
509 /**
510 * Get the port.
511 *
512 * @return the port.
513 */
514 @JsonProperty("port")
515 public Port port() {
516 return this.port;
517 }
518
519 /**
520 * Get the queue ID.
521 *
522 * @return the queue ID.
523 */
524 @JsonProperty("queueId")
525 public int queueId() {
526 return this.queueId;
527 }
528
529 /**
530 * Convert the action to a string.
531 *
532 * The string has the following form:
533 * [port=XXX queueId=XXX]
534 *
535 * @return the action as a string.
536 */
537 @Override
538 public String toString() {
539 String ret = "[";
540 ret += "port=" + port.toString();
541 ret += " queueId=" + queueId;
542 ret += "]";
543
544 return ret;
545 }
546 }
547
548 private ActionValues actionType; // The action type
549
550 //
551 // The actions.
552 // NOTE: Only one action should be set.
553 //
554 private ActionOutput actionOutput;
555 private ActionSetVlanId actionSetVlanId;
556 private ActionSetVlanPriority actionSetVlanPriority;
557 private ActionStripVlan actionStripVlan;
558 private ActionSetEthernetAddr actionSetEthernetSrcAddr;
559 private ActionSetEthernetAddr actionSetEthernetDstAddr;
560 private ActionSetIPv4Addr actionSetIPv4SrcAddr;
561 private ActionSetIPv4Addr actionSetIPv4DstAddr;
562 private ActionSetIpToS actionSetIpToS;
563 private ActionSetTcpUdpPort actionSetTcpUdpSrcPort;
564 private ActionSetTcpUdpPort actionSetTcpUdpDstPort;
565 private ActionEnqueue actionEnqueue;
566
567 /**
568 * Default constructor.
569 */
570 public FlowEntryAction() {
571 actionType = ActionValues.ACTION_VENDOR; // XXX: Initial value
572 }
573
574 /**
575 * Get the action type.
576 *
577 * @return the action type.
578 */
579 @JsonProperty("actionType")
580 public ActionValues actionType() { return actionType; }
581
582 /**
583 * Get the output action.
584 *
585 * @return the output action.
586 */
587 @JsonProperty("actionOutput")
588 public ActionOutput actionOutput() { return actionOutput; }
589
590 /**
591 * Set the output action on a port.
592 *
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700593 * @param action the action to set.
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800594 */
595 @JsonProperty("actionOutput")
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700596 public void setActionOutput(ActionOutput action) {
597 actionOutput = action;
598 actionType = ActionValues.ACTION_OUTPUT;
599 }
600
601 /**
602 * Set the output action on a port.
603 *
604 * @param port the output port to set.
605 */
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800606 public void setActionOutput(Port port) {
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700607 actionOutput = new ActionOutput(port);
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800608 actionType = ActionValues.ACTION_OUTPUT;
609 }
610
611 /**
612 * Set the output action to controller.
613 *
614 * @param maxLen the maximum length (in bytes) to send to controller.
615 */
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800616 public void setActionOutputToController(short maxLen) {
617 Port port = new Port(Port.PortValues.PORT_CONTROLLER);
618 actionOutput = new ActionOutput(port, maxLen);
619 actionType = ActionValues.ACTION_OUTPUT;
620 }
621
622 /**
623 * Get the action to set the VLAN ID.
624 *
625 * @return the action to set the VLAN ID.
626 */
627 @JsonProperty("actionSetVlanId")
628 public ActionSetVlanId actionSetVlanId() { return actionSetVlanId; }
629
630 /**
631 * Set the action to set the VLAN ID.
632 *
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700633 * @param action the action to set.
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800634 */
635 @JsonProperty("actionSetVlanId")
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700636 public void setActionSetVlanId(ActionSetVlanId action) {
637 actionSetVlanId = action;
638 actionType = ActionValues.ACTION_SET_VLAN_VID;
639 }
640
641 /**
642 * Set the action to set the VLAN ID.
643 *
644 * @param vlanId the VLAN ID to set.
645 */
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800646 public void setActionSetVlanId(short vlanId) {
647 actionSetVlanId = new ActionSetVlanId(vlanId);
648 actionType = ActionValues.ACTION_SET_VLAN_VID;
649 }
650
651 /**
652 * Get the action to set the VLAN priority.
653 *
654 * @return the action to set the VLAN priority.
655 */
656 @JsonProperty("actionSetVlanPriority")
657 public ActionSetVlanPriority actionSetVlanPriority() {
658 return actionSetVlanPriority;
659 }
660
661 /**
662 * Set the action to set the VLAN priority.
663 *
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700664 * @param action the action to set.
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800665 */
666 @JsonProperty("actionSetVlanPriority")
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700667 public void setActionSetVlanPriority(ActionSetVlanPriority action) {
668 actionSetVlanPriority = action;
669 actionType = ActionValues.ACTION_SET_VLAN_PCP;
670 }
671
672 /**
673 * Set the action to set the VLAN priority.
674 *
675 * @param vlanPriority the VLAN priority to set.
676 */
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800677 public void setActionSetVlanPriority(byte vlanPriority) {
678 actionSetVlanPriority = new ActionSetVlanPriority(vlanPriority);
679 actionType = ActionValues.ACTION_SET_VLAN_PCP;
680 }
681
682 /**
683 * Get the action to strip the VLAN header.
684 *
685 * @return the action to strip the VLAN header.
686 */
687 @JsonProperty("actionStripVlan")
688 public ActionStripVlan actionStripVlan() {
689 return actionStripVlan;
690 }
691
692 /**
693 * Set the action to strip the VLAN header.
694 *
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700695 * @param action the action to set.
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800696 */
697 @JsonProperty("actionStripVlan")
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700698 public void setActionStripVlan(ActionStripVlan action) {
699 actionStripVlan = action;
700 actionType = ActionValues.ACTION_STRIP_VLAN;
701 }
702
703 /**
704 * Set the action to strip the VLAN header.
705 *
706 * @param stripVlan if true, strip the VLAN header.
707 */
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800708 public void setActionStripVlan(boolean stripVlan) {
709 actionStripVlan = new ActionStripVlan(stripVlan);
710 actionType = ActionValues.ACTION_STRIP_VLAN;
711 }
712
713 /**
714 * Get the action to set the Ethernet source address.
715 *
716 * @return the action to set the Ethernet source address.
717 */
718 @JsonProperty("actionSetEthernetSrcAddr")
719 public ActionSetEthernetAddr actionSetEthernetSrcAddr() {
720 return actionSetEthernetSrcAddr;
721 }
722
723 /**
724 * Set the action to set the Ethernet source address.
725 *
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700726 * @param action the action to set.
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800727 */
728 @JsonProperty("actionSetEthernetSrcAddr")
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700729 public void setActionSetEthernetSrcAddr(ActionSetEthernetAddr action) {
730 actionSetEthernetSrcAddr = action;
731 actionType = ActionValues.ACTION_SET_DL_SRC;
732 }
733
734 /**
735 * Set the action to set the Ethernet source address.
736 *
737 * @param addr the MAC address to set as the Ethernet source address.
738 */
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800739 public void setActionSetEthernetSrcAddr(MACAddress addr) {
740 actionSetEthernetSrcAddr = new ActionSetEthernetAddr(addr);
741 actionType = ActionValues.ACTION_SET_DL_SRC;
742 }
743
744 /**
745 * Get the action to set the Ethernet destination address.
746 *
747 * @return the action to set the Ethernet destination address.
748 */
749 @JsonProperty("actionSetEthernetDstAddr")
750 public ActionSetEthernetAddr actionSetEthernetDstAddr() {
751 return actionSetEthernetDstAddr;
752 }
753
754 /**
755 * Set the action to set the Ethernet destination address.
756 *
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700757 * @param action the action to set.
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800758 */
759 @JsonProperty("actionSetEthernetDstAddr")
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700760 public void setActionSetEthernetDstAddr(ActionSetEthernetAddr action) {
761 actionSetEthernetDstAddr = action;
762 actionType = ActionValues.ACTION_SET_DL_DST;
763 }
764
765 /**
766 * Set the action to set the Ethernet destination address.
767 *
768 * @param addr the MAC address to set as the Ethernet destination address.
769 */
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800770 public void setActionSetEthernetDstAddr(MACAddress addr) {
771 actionSetEthernetDstAddr = new ActionSetEthernetAddr(addr);
772 actionType = ActionValues.ACTION_SET_DL_DST;
773 }
774
775 /**
776 * Get the action to set the IPv4 source address.
777 *
778 * @return the action to set the IPv4 source address.
779 */
780 @JsonProperty("actionSetIPv4SrcAddr")
781 public ActionSetIPv4Addr actionSetIPv4SrcAddr() {
782 return actionSetIPv4SrcAddr;
783 }
784
785 /**
786 * Set the action to set the IPv4 source address.
787 *
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700788 * @param action the action to set.
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800789 */
790 @JsonProperty("actionSetIPv4SrcAddr")
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700791 public void setActionSetIPv4SrcAddr(ActionSetIPv4Addr action) {
792 actionSetIPv4SrcAddr = action;
793 actionType = ActionValues.ACTION_SET_NW_SRC;
794 }
795
796 /**
797 * Set the action to set the IPv4 source address.
798 *
799 * @param addr the IPv4 address to set as the IPv4 source address.
800 */
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800801 public void setActionSetIPv4SrcAddr(IPv4 addr) {
802 actionSetIPv4SrcAddr = new ActionSetIPv4Addr(addr);
803 actionType = ActionValues.ACTION_SET_NW_SRC;
804 }
805
806 /**
807 * Get the action to set the IPv4 destination address.
808 *
809 * @return the action to set the IPv4 destination address.
810 */
811 @JsonProperty("actionSetIPv4DstAddr")
812 public ActionSetIPv4Addr actionSetIPv4DstAddr() {
813 return actionSetIPv4DstAddr;
814 }
815
816 /**
817 * Set the action to set the IPv4 destination address.
818 *
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700819 * @param action the action to set.
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800820 */
821 @JsonProperty("actionSetIPv4DstAddr")
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700822 public void setActionSetIPv4DstAddr(ActionSetIPv4Addr action) {
823 actionSetIPv4DstAddr = action;
824 actionType = ActionValues.ACTION_SET_NW_DST;
825 }
826
827 /**
828 * Set the action to set the IPv4 destination address.
829 *
830 * @param addr the IPv4 address to set as the IPv4 destination address.
831 */
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800832 public void setActionSetIPv4DstAddr(IPv4 addr) {
833 actionSetIPv4DstAddr = new ActionSetIPv4Addr(addr);
834 actionType = ActionValues.ACTION_SET_NW_DST;
835 }
836
837 /**
838 * Get the action to set the IP ToS (DSCP field, 6 bits).
839 *
840 * @return the action to set the IP ToS (DSCP field, 6 bits).
841 */
842 @JsonProperty("actionSetIpToS")
843 public ActionSetIpToS actionSetIpToS() {
844 return actionSetIpToS;
845 }
846
847 /**
848 * Set the action to set the IP ToS (DSCP field, 6 bits).
849 *
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700850 * @param action the action to set.
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800851 */
852 @JsonProperty("actionSetIpToS")
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700853 public void setActionSetIpToS(ActionSetIpToS action) {
854 actionSetIpToS = action;
855 actionType = ActionValues.ACTION_SET_NW_TOS;
856 }
857
858 /**
859 * Set the action to set the IP ToS (DSCP field, 6 bits).
860 *
861 * @param ipToS the IP ToS (DSCP field, 6 bits) to set.
862 */
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800863 public void setActionSetIpToS(byte ipToS) {
864 actionSetIpToS = new ActionSetIpToS(ipToS);
865 actionType = ActionValues.ACTION_SET_NW_TOS;
866 }
867
868 /**
869 * Get the action to set the TCP/UDP source port.
870 *
871 * @return the action to set the TCP/UDP source port.
872 */
873 @JsonProperty("actionSetTcpUdpSrcPort")
874 public ActionSetTcpUdpPort actionSetTcpUdpSrcPort() {
875 return actionSetTcpUdpSrcPort;
876 }
877
878 /**
879 * Set the action to set the TCP/UDP source port.
880 *
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700881 * @param action the action to set.
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800882 */
883 @JsonProperty("actionSetTcpUdpSrcPort")
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700884 public void setActionSetTcpUdpSrcPort(ActionSetTcpUdpPort action) {
885 actionSetTcpUdpSrcPort = action;
886 actionType = ActionValues.ACTION_SET_TP_SRC;
887 }
888
889 /**
890 * Set the action to set the TCP/UDP source port.
891 *
892 * @param port the TCP/UDP port to set as the TCP/UDP source port.
893 */
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800894 public void setActionSetTcpUdpSrcPort(short port) {
895 actionSetTcpUdpSrcPort = new ActionSetTcpUdpPort(port);
896 actionType = ActionValues.ACTION_SET_TP_SRC;
897 }
898
899 /**
900 * Get the action to set the TCP/UDP destination port.
901 *
902 * @return the action to set the TCP/UDP destination port.
903 */
904 @JsonProperty("actionSetTcpUdpDstPort")
905 public ActionSetTcpUdpPort actionSetTcpUdpDstPort() {
906 return actionSetTcpUdpDstPort;
907 }
908
909 /**
910 * Set the action to set the TCP/UDP destination port.
911 *
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700912 * @param action the action to set.
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800913 */
914 @JsonProperty("actionSetTcpUdpDstPort")
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700915 public void setActionSetTcpUdpDstPort(ActionSetTcpUdpPort action) {
916 actionSetTcpUdpDstPort = action;
917 actionType = ActionValues.ACTION_SET_TP_DST;
918 }
919
920 /**
921 * Set the action to set the TCP/UDP destination port.
922 *
923 * @param port the TCP/UDP port to set as the TCP/UDP destination port.
924 */
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800925 public void setActionSetTcpUdpDstPort(short port) {
926 actionSetTcpUdpDstPort = new ActionSetTcpUdpPort(port);
927 actionType = ActionValues.ACTION_SET_TP_DST;
928 }
929
930 /**
931 * Get the action to output to queue on a port.
932 *
933 * @return the action to output to queue on a port.
934 */
935 @JsonProperty("actionEnqueue")
936 public ActionEnqueue actionEnqueue() { return actionEnqueue; }
937
938 /**
939 * Set the action to output to queue on a port.
940 *
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700941 * @param action the action to set.
942 */
943 @JsonProperty("actionEnqueue")
944 public void setActionEnqueue(ActionEnqueue action) {
945 actionEnqueue = action;
946 actionType = ActionValues.ACTION_ENQUEUE;
947 }
948
949 /**
950 * Set the action to output to queue on a port.
951 *
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800952 * @param port the port to set.
953 * @param int queueId the queue ID to set.
954 */
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800955 public void setActionEnqueue(Port port, int queueId) {
956 actionEnqueue = new ActionEnqueue(port, queueId);
957 actionType = ActionValues.ACTION_ENQUEUE;
958 }
959
960 /**
961 * Convert the set of actions to a string.
962 *
963 * The string has the following form:
964 * [type=XXX action=XXX]
965 *
966 * @return the set of actions as a string.
967 */
968 @Override
969 public String toString() {
970 String ret = "[";
971 ret += "type=" + actionType;
972 switch (actionType) {
973 case ACTION_OUTPUT:
974 ret += " action=" + actionOutput.toString();
975 break;
976 case ACTION_SET_VLAN_VID:
977 ret += " action=" + actionSetVlanId.toString();
978 break;
979 case ACTION_SET_VLAN_PCP:
980 ret += " action=" + actionSetVlanPriority.toString();
981 break;
982 case ACTION_STRIP_VLAN:
983 ret += " action=" + actionStripVlan.toString();
984 break;
985 case ACTION_SET_DL_SRC:
986 ret += " action=" + actionSetEthernetSrcAddr.toString();
987 break;
988 case ACTION_SET_DL_DST:
989 ret += " action=" + actionSetEthernetDstAddr.toString();
990 break;
991 case ACTION_SET_NW_SRC:
992 ret += " action=" + actionSetIPv4SrcAddr.toString();
993 break;
994 case ACTION_SET_NW_DST:
995 ret += " action=" + actionSetIPv4DstAddr.toString();
996 break;
997 case ACTION_SET_NW_TOS:
998 ret += " action=" + actionSetIpToS.toString();
999 break;
1000 case ACTION_SET_TP_SRC:
1001 ret += " action=" + actionSetTcpUdpSrcPort.toString();
1002 break;
1003 case ACTION_SET_TP_DST:
1004 ret += " action=" + actionSetTcpUdpDstPort.toString();
1005 break;
1006 case ACTION_ENQUEUE:
1007 ret += " action=" + actionEnqueue.toString();
1008 break;
1009 }
1010 ret += "]";
1011
1012 return ret;
1013 }
1014}