blob: 22aef98cd82a3322d137aa60afae842d6c2cb198 [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;
Pavlin Radoslavovede97582013-03-08 18:57:28 -08004
5import org.codehaus.jackson.annotate.JsonProperty;
6
7/**
8 * The class representing a single Flow Entry action.
9 *
10 * A set of Flow Entry actions need to be applied to each packet.
11 */
12public class FlowEntryAction {
13 /**
14 * Special action values.
15 *
16 * Those values are taken as-is from the OpenFlow-v1.0.0 specification
17 * (pp 21-22).
18 */
19 public enum ActionValues {
20 ACTION_OUTPUT ((short)0x0), // Output to switch port
21 ACTION_SET_VLAN_VID ((short)0x1), // Set the 802.1q VLAN id
22 ACTION_SET_VLAN_PCP ((short)0x2), // Set the 802.1q priority
23 ACTION_STRIP_VLAN ((short)0x3), // Strip the 802.1q header
24 ACTION_SET_DL_SRC ((short)0x4), // Ethernet source address
25 ACTION_SET_DL_DST ((short)0x5), // Ethernet destination address
26 ACTION_SET_NW_SRC ((short)0x6), // IP source address
27 ACTION_SET_NW_DST ((short)0x7), // IP destination address
28 ACTION_SET_NW_TOS ((short)0x8), // IP ToS (DSCP field, 6 bits)
29 ACTION_SET_TP_SRC ((short)0x9), // TCP/UDP source port
30 ACTION_SET_TP_DST ((short)0xa), // TCP/UDP destination port
31 ACTION_ENQUEUE ((short)0xb), // Output to queue on port
32 ACTION_VENDOR ((short)0xffff); // Vendor-specific
33
34 private final short value; // The value
35
36 /**
37 * Constructor for a given value.
38 *
39 * @param value the value to use for the initialization.
40 */
41 private ActionValues(short value) {
42 this.value = value;
43 }
44 }
45
46 /**
47 * Action structure for ACTION_OUTPUT: Output to switch port.
48 */
49 public class ActionOutput {
50 private Port port; // Output port
51 private short maxLen; // Max. length (in bytes) to send to controller
52 // if the port is set to PORT_CONTROLLER
53
54 /**
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -070055 * Default constructor.
56 */
57 public ActionOutput() {
58 this.port = null;
59 this.maxLen = 0;
60 }
61
62
63 /**
Pavlin Radoslavovede97582013-03-08 18:57:28 -080064 * Constructor for a given output port and maximum length.
65 *
66 * @param port the output port to set.
67 * @param maxLen the maximum length (in bytes) to send to controller
68 * if the port is set to PORT_CONTROLLER.
69 */
70 public ActionOutput(Port port, short maxLen) {
71 this.port = port;
72 this.maxLen = maxLen;
73 }
74
75 /**
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -070076 * Constructor for a given output port.
77 *
78 * @param port the output port to set.
79 */
80 public ActionOutput(Port port) {
81 this.port = port;
82 this.maxLen = 0;
83 }
84
85 /**
Pavlin Radoslavovede97582013-03-08 18:57:28 -080086 * Get the output port.
87 *
88 * @return the output port.
89 */
90 @JsonProperty("port")
91 public Port port() {
92 return this.port;
93 }
94
95 /**
96 * Get the maximum length (in bytes) to send to controller if the
97 * port is set to PORT_CONTROLLER.
98 *
99 * @return the maximum length (in bytes) to send to controller if the
100 * port is set to PORT_CONTROLLER.
101 */
102 @JsonProperty("maxLen")
103 public short maxLen() {
104 return this.maxLen;
105 }
106
107 /**
108 * Convert the action to a string.
109 *
110 * The string has the following form:
111 * [port=XXX maxLen=XXX]
112 *
113 * @return the action as a string.
114 */
115 @Override
116 public String toString() {
117 String ret = "[";
118 ret += "port=" + port.toString();
119 ret += " maxLen=" + maxLen;
120 ret += "]";
121
122 return ret;
123 }
124 }
125
126 /**
127 * Action structure for ACTION_SET_VLAN_VID: Set the 802.1q VLAN id
128 */
129 public class ActionSetVlanId {
130 private short vlanId; // The VLAN ID to set
131
132 /**
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700133 * Default constructor.
134 */
135 public ActionSetVlanId() {
136 this.vlanId = 0;
137 }
138
139 /**
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800140 * Constructor for a given VLAN ID.
141 *
142 * @param vlanId the VLAN ID to set.
143 */
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700144 public ActionSetVlanId(short vlanId) {
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800145 this.vlanId = vlanId;
146 }
147
148 /**
149 * Get the VLAN ID.
150 *
151 * @return the VLAN ID.
152 */
153 @JsonProperty("vlanId")
154 public short vlanId() {
155 return this.vlanId;
156 }
157
158 /**
159 * Convert the action to a string.
160 *
161 * The string has the following form:
162 * [vlanId=XXX]
163 *
164 * @return the action as a string.
165 */
166 @Override
167 public String toString() {
168 String ret = "[";
169 ret += "vlanId=" + this.vlanId;
170 ret += "]";
171
172 return ret;
173 }
174 }
175
176 /**
177 * Action structure for ACTION_SET_VLAN_PCP: Set the 802.1q priority
178 */
179 public class ActionSetVlanPriority {
180 private byte vlanPriority; // The VLAN priority to set
181
182 /**
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700183 * Default constructor.
184 */
185 public ActionSetVlanPriority() {
186 this.vlanPriority = 0;
187 }
188
189 /**
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800190 * Constructor for a given VLAN priority.
191 *
192 * @param vlanPriority the VLAN priority to set.
193 */
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700194 public ActionSetVlanPriority(byte vlanPriority) {
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800195 this.vlanPriority = vlanPriority;
196 }
197
198 /**
199 * Get the VLAN priority.
200 *
201 * @return the VLAN priority.
202 */
203 @JsonProperty("vlanPriority")
204 public byte vlanPriority() {
205 return this.vlanPriority;
206 }
207
208 /**
209 * Convert the action to a string.
210 *
211 * The string has the following form:
212 * [vlanPriority=XXX]
213 *
214 * @return the action as a string.
215 */
216 @Override
217 public String toString() {
218 String ret = "[";
219 ret += "vlanPriority=" + this.vlanPriority;
220 ret += "]";
221
222 return ret;
223 }
224 }
225
226 /**
227 * Action structure for ACTION_STRIP_VLAN: Strip the 802.1q header
228 */
229 public class ActionStripVlan {
230 private boolean stripVlan; // If true, strip the VLAN header
231
232 /**
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700233 * Default constructor.
234 */
235 public ActionStripVlan() {
236 this.stripVlan = false;
237 }
238
239 /**
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800240 * Constructor for a given boolean flag.
241 *
242 * @param stripVlan if true, strip the VLAN header.
243 */
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700244 public ActionStripVlan(boolean stripVlan) {
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800245 this.stripVlan = stripVlan;
246 }
247
248 /**
249 * Get the boolean flag whether the VLAN header should be stripped.
250 *
251 * @return the boolean flag whether the VLAN header should be stripped.
252 */
253 @JsonProperty("stripVlan")
254 public boolean stripVlan() {
255 return this.stripVlan;
256 }
257
258 /**
259 * Convert the action to a string.
260 *
261 * The string has the following form:
262 * [stripVlan=XXX]
263 *
264 * @return the action as a string.
265 */
266 @Override
267 public String toString() {
268 String ret = "[";
269 ret += "stripVlan=" + this.stripVlan;
270 ret += "]";
271
272 return ret;
273 }
274 }
275
276 /**
277 * Action structure for ACTION_SET_DL_SRC and ACTION_SET_DL_DST:
278 * Set the Ethernet source/destination address.
279 */
280 public class ActionSetEthernetAddr {
281 private MACAddress addr; // The MAC address to set
282
283 /**
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700284 * Default constructor.
285 */
286 public ActionSetEthernetAddr() {
287 this.addr = null;
288 }
289
290 /**
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800291 * Constructor for a given MAC address.
292 *
293 * @param addr the MAC address to set.
294 */
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700295 public ActionSetEthernetAddr(MACAddress addr) {
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800296 this.addr = addr;
297 }
298
299 /**
300 * Get the MAC address.
301 *
302 * @return the MAC address.
303 */
304 @JsonProperty("addr")
305 public MACAddress addr() {
306 return this.addr;
307 }
308
309 /**
310 * Convert the action to a string.
311 *
312 * The string has the following form:
313 * [addr=XXX]
314 *
315 * @return the action as a string.
316 */
317 @Override
318 public String toString() {
319 String ret = "[";
320 ret += "addr=" + addr.toString();
321 ret += "]";
322
323 return ret;
324 }
325 }
326
327 /**
328 * Action structure for ACTION_SET_NW_SRC and ACTION_SET_NW_DST:
329 * Set the IPv4 source/destination address.
330 */
331 public class ActionSetIPv4Addr {
332 private IPv4 addr; // The IPv4 address to set
333
334 /**
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700335 * Default constructor.
336 */
337 public ActionSetIPv4Addr() {
338 this.addr = null;
339 }
340
341 /**
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800342 * Constructor for a given IPv4 address.
343 *
344 * @param addr the IPv4 address to set.
345 */
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700346 public ActionSetIPv4Addr(IPv4 addr) {
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800347 this.addr = addr;
348 }
349
350 /**
351 * Get the IPv4 address.
352 *
353 * @return the IPv4 address.
354 */
355 @JsonProperty("addr")
356 public IPv4 addr() {
357 return this.addr;
358 }
359
360 /**
361 * Convert the action to a string.
362 *
363 * The string has the following form:
364 * [addr=XXX]
365 *
366 * @return the action as a string.
367 */
368 @Override
369 public String toString() {
370 String ret = "[";
371 ret += "addr=" + addr.toString();
372 ret += "]";
373
374 return ret;
375 }
376 }
377
378 /**
379 * Action structure for ACTION_SET_NW_TOS:
380 * Set the IP ToS (DSCP field, 6 bits).
381 */
382 public class ActionSetIpToS {
383 private byte ipToS; // The IP ToS to set DSCP field, 6 bits)
384
385 /**
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700386 * Default constructor.
387 */
388 public ActionSetIpToS() {
389 this.ipToS = 0;
390 }
391
392 /**
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800393 * Constructor for a given IP ToS (DSCP field, 6 bits).
394 *
395 * @param ipToS the IP ToS (DSCP field, 6 bits) to set.
396 */
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700397 public ActionSetIpToS(byte ipToS) {
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800398 this.ipToS = ipToS;
399 }
400
401 /**
402 * Get the IP ToS (DSCP field, 6 bits).
403 *
404 * @return the IP ToS (DSCP field, 6 bits).
405 */
406 @JsonProperty("ipToS")
407 public byte ipToS() {
408 return this.ipToS;
409 }
410
411 /**
412 * Convert the action to a string.
413 *
414 * The string has the following form:
415 * [ipToS=XXX]
416 *
417 * @return the action as a string.
418 */
419 @Override
420 public String toString() {
421 String ret = "[";
422 ret += "ipToS=" + ipToS;
423 ret += "]";
424
425 return ret;
426 }
427 }
428
429 /**
430 * Action structure for ACTION_SET_TP_SRC and ACTION_SET_TP_DST:
431 * Set the TCP/UDP source/destination port.
432 */
433 public class ActionSetTcpUdpPort {
434 private short port; // The TCP/UDP port to set
435
436 /**
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700437 * Default constructor.
438 */
439 public ActionSetTcpUdpPort() {
440 this.port = 0;
441 }
442
443 /**
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800444 * Constructor for a given TCP/UDP port.
445 *
446 * @param port the TCP/UDP port to set.
447 */
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700448 public ActionSetTcpUdpPort(short port) {
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800449 this.port = port;
450 }
451
452 /**
453 * Get the TCP/UDP port.
454 *
455 * @return the TCP/UDP port.
456 */
457 @JsonProperty("port")
458 public short port() {
459 return this.port;
460 }
461
462 /**
463 * Convert the action to a string.
464 *
465 * The string has the following form:
466 * [port=XXX]
467 *
468 * @return the action as a string.
469 */
470 @Override
471 public String toString() {
472 String ret = "[";
473 ret += "port=" + port;
474 ret += "]";
475
476 return ret;
477 }
478 }
479
480 /**
481 * Action structure for ACTION_ENQUEUE: Output to queue on port.
482 */
483 public class ActionEnqueue {
484 private Port port; // Port that queue belongs. Should
485 // refer to a valid physical port
486 // (i.e. < PORT_MAX) or PORT_IN_PORT
487 private int queueId; // Where to enqueue the packets
488
489 /**
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700490 * Default constructor.
491 */
492 public ActionEnqueue() {
493 this.port = null;
494 this.queueId = 0;
495 }
496
497 /**
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800498 * Constructor for a given port and queue ID.
499 *
500 * @param port the port to set.
501 * @param queueId the queue ID on the port.
502 */
503 public ActionEnqueue(Port port, int queueId) {
504 this.port = port;
505 this.queueId = queueId;
506 }
507
508 /**
509 * Get the port.
510 *
511 * @return the port.
512 */
513 @JsonProperty("port")
514 public Port port() {
515 return this.port;
516 }
517
518 /**
519 * Get the queue ID.
520 *
521 * @return the queue ID.
522 */
523 @JsonProperty("queueId")
524 public int queueId() {
525 return this.queueId;
526 }
527
528 /**
529 * Convert the action to a string.
530 *
531 * The string has the following form:
532 * [port=XXX queueId=XXX]
533 *
534 * @return the action as a string.
535 */
536 @Override
537 public String toString() {
538 String ret = "[";
539 ret += "port=" + port.toString();
540 ret += " queueId=" + queueId;
541 ret += "]";
542
543 return ret;
544 }
545 }
546
547 private ActionValues actionType; // The action type
548
549 //
550 // The actions.
551 // NOTE: Only one action should be set.
552 //
553 private ActionOutput actionOutput;
554 private ActionSetVlanId actionSetVlanId;
555 private ActionSetVlanPriority actionSetVlanPriority;
556 private ActionStripVlan actionStripVlan;
557 private ActionSetEthernetAddr actionSetEthernetSrcAddr;
558 private ActionSetEthernetAddr actionSetEthernetDstAddr;
559 private ActionSetIPv4Addr actionSetIPv4SrcAddr;
560 private ActionSetIPv4Addr actionSetIPv4DstAddr;
561 private ActionSetIpToS actionSetIpToS;
562 private ActionSetTcpUdpPort actionSetTcpUdpSrcPort;
563 private ActionSetTcpUdpPort actionSetTcpUdpDstPort;
564 private ActionEnqueue actionEnqueue;
565
566 /**
567 * Default constructor.
568 */
569 public FlowEntryAction() {
570 actionType = ActionValues.ACTION_VENDOR; // XXX: Initial value
571 }
572
573 /**
574 * Get the action type.
575 *
576 * @return the action type.
577 */
578 @JsonProperty("actionType")
579 public ActionValues actionType() { return actionType; }
580
581 /**
582 * Get the output action.
583 *
584 * @return the output action.
585 */
586 @JsonProperty("actionOutput")
587 public ActionOutput actionOutput() { return actionOutput; }
588
589 /**
590 * Set the output action on a port.
591 *
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700592 * @param action the action to set.
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800593 */
594 @JsonProperty("actionOutput")
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700595 public void setActionOutput(ActionOutput action) {
596 actionOutput = action;
597 actionType = ActionValues.ACTION_OUTPUT;
598 }
599
600 /**
601 * Set the output action on a port.
602 *
603 * @param port the output port to set.
604 */
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800605 public void setActionOutput(Port port) {
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700606 actionOutput = new ActionOutput(port);
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800607 actionType = ActionValues.ACTION_OUTPUT;
608 }
609
610 /**
611 * Set the output action to controller.
612 *
613 * @param maxLen the maximum length (in bytes) to send to controller.
614 */
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800615 public void setActionOutputToController(short maxLen) {
616 Port port = new Port(Port.PortValues.PORT_CONTROLLER);
617 actionOutput = new ActionOutput(port, maxLen);
618 actionType = ActionValues.ACTION_OUTPUT;
619 }
620
621 /**
622 * Get the action to set the VLAN ID.
623 *
624 * @return the action to set the VLAN ID.
625 */
626 @JsonProperty("actionSetVlanId")
627 public ActionSetVlanId actionSetVlanId() { return actionSetVlanId; }
628
629 /**
630 * Set the action to set the VLAN ID.
631 *
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700632 * @param action the action to set.
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800633 */
634 @JsonProperty("actionSetVlanId")
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700635 public void setActionSetVlanId(ActionSetVlanId action) {
636 actionSetVlanId = action;
637 actionType = ActionValues.ACTION_SET_VLAN_VID;
638 }
639
640 /**
641 * Set the action to set the VLAN ID.
642 *
643 * @param vlanId the VLAN ID to set.
644 */
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800645 public void setActionSetVlanId(short vlanId) {
646 actionSetVlanId = new ActionSetVlanId(vlanId);
647 actionType = ActionValues.ACTION_SET_VLAN_VID;
648 }
649
650 /**
651 * Get the action to set the VLAN priority.
652 *
653 * @return the action to set the VLAN priority.
654 */
655 @JsonProperty("actionSetVlanPriority")
656 public ActionSetVlanPriority actionSetVlanPriority() {
657 return actionSetVlanPriority;
658 }
659
660 /**
661 * Set the action to set the VLAN priority.
662 *
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700663 * @param action the action to set.
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800664 */
665 @JsonProperty("actionSetVlanPriority")
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700666 public void setActionSetVlanPriority(ActionSetVlanPriority action) {
667 actionSetVlanPriority = action;
668 actionType = ActionValues.ACTION_SET_VLAN_PCP;
669 }
670
671 /**
672 * Set the action to set the VLAN priority.
673 *
674 * @param vlanPriority the VLAN priority to set.
675 */
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800676 public void setActionSetVlanPriority(byte vlanPriority) {
677 actionSetVlanPriority = new ActionSetVlanPriority(vlanPriority);
678 actionType = ActionValues.ACTION_SET_VLAN_PCP;
679 }
680
681 /**
682 * Get the action to strip the VLAN header.
683 *
684 * @return the action to strip the VLAN header.
685 */
686 @JsonProperty("actionStripVlan")
687 public ActionStripVlan actionStripVlan() {
688 return actionStripVlan;
689 }
690
691 /**
692 * Set the action to strip the VLAN header.
693 *
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700694 * @param action the action to set.
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800695 */
696 @JsonProperty("actionStripVlan")
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700697 public void setActionStripVlan(ActionStripVlan action) {
698 actionStripVlan = action;
699 actionType = ActionValues.ACTION_STRIP_VLAN;
700 }
701
702 /**
703 * Set the action to strip the VLAN header.
704 *
705 * @param stripVlan if true, strip the VLAN header.
706 */
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800707 public void setActionStripVlan(boolean stripVlan) {
708 actionStripVlan = new ActionStripVlan(stripVlan);
709 actionType = ActionValues.ACTION_STRIP_VLAN;
710 }
711
712 /**
713 * Get the action to set the Ethernet source address.
714 *
715 * @return the action to set the Ethernet source address.
716 */
717 @JsonProperty("actionSetEthernetSrcAddr")
718 public ActionSetEthernetAddr actionSetEthernetSrcAddr() {
719 return actionSetEthernetSrcAddr;
720 }
721
722 /**
723 * Set the action to set the Ethernet source address.
724 *
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700725 * @param action the action to set.
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800726 */
727 @JsonProperty("actionSetEthernetSrcAddr")
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700728 public void setActionSetEthernetSrcAddr(ActionSetEthernetAddr action) {
729 actionSetEthernetSrcAddr = action;
730 actionType = ActionValues.ACTION_SET_DL_SRC;
731 }
732
733 /**
734 * Set the action to set the Ethernet source address.
735 *
736 * @param addr the MAC address to set as the Ethernet source address.
737 */
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800738 public void setActionSetEthernetSrcAddr(MACAddress addr) {
739 actionSetEthernetSrcAddr = new ActionSetEthernetAddr(addr);
740 actionType = ActionValues.ACTION_SET_DL_SRC;
741 }
742
743 /**
744 * Get the action to set the Ethernet destination address.
745 *
746 * @return the action to set the Ethernet destination address.
747 */
748 @JsonProperty("actionSetEthernetDstAddr")
749 public ActionSetEthernetAddr actionSetEthernetDstAddr() {
750 return actionSetEthernetDstAddr;
751 }
752
753 /**
754 * Set the action to set the Ethernet destination address.
755 *
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700756 * @param action the action to set.
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800757 */
758 @JsonProperty("actionSetEthernetDstAddr")
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700759 public void setActionSetEthernetDstAddr(ActionSetEthernetAddr action) {
760 actionSetEthernetDstAddr = action;
761 actionType = ActionValues.ACTION_SET_DL_DST;
762 }
763
764 /**
765 * Set the action to set the Ethernet destination address.
766 *
767 * @param addr the MAC address to set as the Ethernet destination address.
768 */
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800769 public void setActionSetEthernetDstAddr(MACAddress addr) {
770 actionSetEthernetDstAddr = new ActionSetEthernetAddr(addr);
771 actionType = ActionValues.ACTION_SET_DL_DST;
772 }
773
774 /**
775 * Get the action to set the IPv4 source address.
776 *
777 * @return the action to set the IPv4 source address.
778 */
779 @JsonProperty("actionSetIPv4SrcAddr")
780 public ActionSetIPv4Addr actionSetIPv4SrcAddr() {
781 return actionSetIPv4SrcAddr;
782 }
783
784 /**
785 * Set the action to set the IPv4 source address.
786 *
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700787 * @param action the action to set.
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800788 */
789 @JsonProperty("actionSetIPv4SrcAddr")
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700790 public void setActionSetIPv4SrcAddr(ActionSetIPv4Addr action) {
791 actionSetIPv4SrcAddr = action;
792 actionType = ActionValues.ACTION_SET_NW_SRC;
793 }
794
795 /**
796 * Set the action to set the IPv4 source address.
797 *
798 * @param addr the IPv4 address to set as the IPv4 source address.
799 */
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800800 public void setActionSetIPv4SrcAddr(IPv4 addr) {
801 actionSetIPv4SrcAddr = new ActionSetIPv4Addr(addr);
802 actionType = ActionValues.ACTION_SET_NW_SRC;
803 }
804
805 /**
806 * Get the action to set the IPv4 destination address.
807 *
808 * @return the action to set the IPv4 destination address.
809 */
810 @JsonProperty("actionSetIPv4DstAddr")
811 public ActionSetIPv4Addr actionSetIPv4DstAddr() {
812 return actionSetIPv4DstAddr;
813 }
814
815 /**
816 * Set the action to set the IPv4 destination address.
817 *
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700818 * @param action the action to set.
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800819 */
820 @JsonProperty("actionSetIPv4DstAddr")
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700821 public void setActionSetIPv4DstAddr(ActionSetIPv4Addr action) {
822 actionSetIPv4DstAddr = action;
823 actionType = ActionValues.ACTION_SET_NW_DST;
824 }
825
826 /**
827 * Set the action to set the IPv4 destination address.
828 *
829 * @param addr the IPv4 address to set as the IPv4 destination address.
830 */
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800831 public void setActionSetIPv4DstAddr(IPv4 addr) {
832 actionSetIPv4DstAddr = new ActionSetIPv4Addr(addr);
833 actionType = ActionValues.ACTION_SET_NW_DST;
834 }
835
836 /**
837 * Get the action to set the IP ToS (DSCP field, 6 bits).
838 *
839 * @return the action to set the IP ToS (DSCP field, 6 bits).
840 */
841 @JsonProperty("actionSetIpToS")
842 public ActionSetIpToS actionSetIpToS() {
843 return actionSetIpToS;
844 }
845
846 /**
847 * Set the action to set the IP ToS (DSCP field, 6 bits).
848 *
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700849 * @param action the action to set.
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800850 */
851 @JsonProperty("actionSetIpToS")
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700852 public void setActionSetIpToS(ActionSetIpToS action) {
853 actionSetIpToS = action;
854 actionType = ActionValues.ACTION_SET_NW_TOS;
855 }
856
857 /**
858 * Set the action to set the IP ToS (DSCP field, 6 bits).
859 *
860 * @param ipToS the IP ToS (DSCP field, 6 bits) to set.
861 */
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800862 public void setActionSetIpToS(byte ipToS) {
863 actionSetIpToS = new ActionSetIpToS(ipToS);
864 actionType = ActionValues.ACTION_SET_NW_TOS;
865 }
866
867 /**
868 * Get the action to set the TCP/UDP source port.
869 *
870 * @return the action to set the TCP/UDP source port.
871 */
872 @JsonProperty("actionSetTcpUdpSrcPort")
873 public ActionSetTcpUdpPort actionSetTcpUdpSrcPort() {
874 return actionSetTcpUdpSrcPort;
875 }
876
877 /**
878 * Set the action to set the TCP/UDP source port.
879 *
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700880 * @param action the action to set.
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800881 */
882 @JsonProperty("actionSetTcpUdpSrcPort")
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700883 public void setActionSetTcpUdpSrcPort(ActionSetTcpUdpPort action) {
884 actionSetTcpUdpSrcPort = action;
885 actionType = ActionValues.ACTION_SET_TP_SRC;
886 }
887
888 /**
889 * Set the action to set the TCP/UDP source port.
890 *
891 * @param port the TCP/UDP port to set as the TCP/UDP source port.
892 */
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800893 public void setActionSetTcpUdpSrcPort(short port) {
894 actionSetTcpUdpSrcPort = new ActionSetTcpUdpPort(port);
895 actionType = ActionValues.ACTION_SET_TP_SRC;
896 }
897
898 /**
899 * Get the action to set the TCP/UDP destination port.
900 *
901 * @return the action to set the TCP/UDP destination port.
902 */
903 @JsonProperty("actionSetTcpUdpDstPort")
904 public ActionSetTcpUdpPort actionSetTcpUdpDstPort() {
905 return actionSetTcpUdpDstPort;
906 }
907
908 /**
909 * Set the action to set the TCP/UDP destination port.
910 *
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700911 * @param action the action to set.
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800912 */
913 @JsonProperty("actionSetTcpUdpDstPort")
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700914 public void setActionSetTcpUdpDstPort(ActionSetTcpUdpPort action) {
915 actionSetTcpUdpDstPort = action;
916 actionType = ActionValues.ACTION_SET_TP_DST;
917 }
918
919 /**
920 * Set the action to set the TCP/UDP destination port.
921 *
922 * @param port the TCP/UDP port to set as the TCP/UDP destination port.
923 */
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800924 public void setActionSetTcpUdpDstPort(short port) {
925 actionSetTcpUdpDstPort = new ActionSetTcpUdpPort(port);
926 actionType = ActionValues.ACTION_SET_TP_DST;
927 }
928
929 /**
930 * Get the action to output to queue on a port.
931 *
932 * @return the action to output to queue on a port.
933 */
934 @JsonProperty("actionEnqueue")
935 public ActionEnqueue actionEnqueue() { return actionEnqueue; }
936
937 /**
938 * Set the action to output to queue on a port.
939 *
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700940 * @param action the action to set.
941 */
942 @JsonProperty("actionEnqueue")
943 public void setActionEnqueue(ActionEnqueue action) {
944 actionEnqueue = action;
945 actionType = ActionValues.ACTION_ENQUEUE;
946 }
947
948 /**
949 * Set the action to output to queue on a port.
950 *
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800951 * @param port the port to set.
952 * @param int queueId the queue ID to set.
953 */
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800954 public void setActionEnqueue(Port port, int queueId) {
955 actionEnqueue = new ActionEnqueue(port, queueId);
956 actionType = ActionValues.ACTION_ENQUEUE;
957 }
958
959 /**
960 * Convert the set of actions to a string.
961 *
962 * The string has the following form:
963 * [type=XXX action=XXX]
964 *
965 * @return the set of actions as a string.
966 */
967 @Override
968 public String toString() {
969 String ret = "[";
970 ret += "type=" + actionType;
971 switch (actionType) {
972 case ACTION_OUTPUT:
973 ret += " action=" + actionOutput.toString();
974 break;
975 case ACTION_SET_VLAN_VID:
976 ret += " action=" + actionSetVlanId.toString();
977 break;
978 case ACTION_SET_VLAN_PCP:
979 ret += " action=" + actionSetVlanPriority.toString();
980 break;
981 case ACTION_STRIP_VLAN:
982 ret += " action=" + actionStripVlan.toString();
983 break;
984 case ACTION_SET_DL_SRC:
985 ret += " action=" + actionSetEthernetSrcAddr.toString();
986 break;
987 case ACTION_SET_DL_DST:
988 ret += " action=" + actionSetEthernetDstAddr.toString();
989 break;
990 case ACTION_SET_NW_SRC:
991 ret += " action=" + actionSetIPv4SrcAddr.toString();
992 break;
993 case ACTION_SET_NW_DST:
994 ret += " action=" + actionSetIPv4DstAddr.toString();
995 break;
996 case ACTION_SET_NW_TOS:
997 ret += " action=" + actionSetIpToS.toString();
998 break;
999 case ACTION_SET_TP_SRC:
1000 ret += " action=" + actionSetTcpUdpSrcPort.toString();
1001 break;
1002 case ACTION_SET_TP_DST:
1003 ret += " action=" + actionSetTcpUdpDstPort.toString();
1004 break;
1005 case ACTION_ENQUEUE:
1006 ret += " action=" + actionEnqueue.toString();
1007 break;
1008 }
1009 ret += "]";
1010
1011 return ret;
1012 }
1013}