blob: f619fea3cd861567fb52fb039d2566f03be9e0e7 [file] [log] [blame]
Jonathan Hart23701d12014-04-03 10:45:48 -07001package net.onrc.onos.core.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.
Ray Milkey269ffb92014-04-03 14:43:30 -07009 * <p/>
Pavlin Radoslavovd5b21db2013-07-29 17:09:53 -070010 * A Flow Entry action that needs to be applied to each packet.
11 * Note that it contains only a single action. Multiple actions are
12 * listed in a list inside @ref FlowEntryActions.
Pavlin Radoslavovede97582013-03-08 18:57:28 -080013 */
14public class FlowEntryAction {
15 /**
16 * Special action values.
Ray Milkey269ffb92014-04-03 14:43:30 -070017 * <p/>
Pavlin Radoslavovede97582013-03-08 18:57:28 -080018 * Those values are taken as-is from the OpenFlow-v1.0.0 specification
19 * (pp 21-22).
20 */
21 public enum ActionValues {
Ray Milkey269ffb92014-04-03 14:43:30 -070022 ACTION_OUTPUT((short) 0x0), // Output to switch port
23 ACTION_SET_VLAN_VID((short) 0x1), // Set the 802.1q VLAN id
24 ACTION_SET_VLAN_PCP((short) 0x2), // Set the 802.1q priority
25 ACTION_STRIP_VLAN((short) 0x3), // Strip the 802.1q header
26 ACTION_SET_DL_SRC((short) 0x4), // Ethernet source address
27 ACTION_SET_DL_DST((short) 0x5), // Ethernet destination address
28 ACTION_SET_NW_SRC((short) 0x6), // IP source address
29 ACTION_SET_NW_DST((short) 0x7), // IP destination address
30 ACTION_SET_NW_TOS((short) 0x8), // IP ToS (DSCP field, 6 bits)
31 ACTION_SET_TP_SRC((short) 0x9), // TCP/UDP source port
32 ACTION_SET_TP_DST((short) 0xa), // TCP/UDP destination port
33 ACTION_ENQUEUE((short) 0xb), // Output to queue on port
34 ACTION_VENDOR((short) 0xffff); // Vendor-specific
Pavlin Radoslavovede97582013-03-08 18:57:28 -080035
Ray Milkey269ffb92014-04-03 14:43:30 -070036 private final short value; // The value
Pavlin Radoslavovede97582013-03-08 18:57:28 -080037
Ray Milkey269ffb92014-04-03 14:43:30 -070038 /**
39 * Constructor for a given value.
40 *
41 * @param value the value to use for the initialization.
42 */
43 private ActionValues(short value) {
44 this.value = value;
45 }
Pavlin Radoslavov020e96c2013-12-11 12:48:04 -080046
Ray Milkey269ffb92014-04-03 14:43:30 -070047 /**
48 * Get the value.
49 *
50 * @return the value.
51 */
52 public short getValue() {
53 return value;
54 }
Pavlin Radoslavovede97582013-03-08 18:57:28 -080055 }
56
57 /**
58 * Action structure for ACTION_OUTPUT: Output to switch port.
59 */
Yuta HIGUCHI382827f2013-10-14 16:06:43 -070060 public static class ActionOutput {
Ray Milkey269ffb92014-04-03 14:43:30 -070061 private Port port; // Output port
62 private short maxLen; // Max. length (in bytes) to send to controller
63 // if the port is set to PORT_CONTROLLER
Pavlin Radoslavovede97582013-03-08 18:57:28 -080064
Ray Milkey269ffb92014-04-03 14:43:30 -070065 /**
66 * Default constructor.
67 */
68 public ActionOutput() {
69 this.port = null;
70 this.maxLen = 0;
71 }
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -070072
Ray Milkey269ffb92014-04-03 14:43:30 -070073 /**
74 * Copy constructor.
75 *
76 * @param other the object to copy from.
77 */
78 public ActionOutput(ActionOutput other) {
79 if (other.port != null)
80 this.port = new Port(other.port);
81 this.maxLen = other.maxLen;
82 }
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -070083
Ray Milkey269ffb92014-04-03 14:43:30 -070084 /**
85 * Constructor from a string.
86 * <p/>
87 * The string has the following form:
88 * [port=XXX maxLen=XXX]
89 *
90 * @param actionStr the action as a string.
91 */
92 public ActionOutput(String actionStr) {
93 this.fromString(actionStr);
94 }
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -070095
Ray Milkey269ffb92014-04-03 14:43:30 -070096 /**
97 * Constructor for a given output port and maximum length.
98 *
99 * @param port the output port to set.
100 * @param maxLen the maximum length (in bytes) to send to controller
101 * if the port is set to PORT_CONTROLLER.
102 */
103 public ActionOutput(Port port, short maxLen) {
104 this.port = port;
105 this.maxLen = maxLen;
106 }
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800107
Ray Milkey269ffb92014-04-03 14:43:30 -0700108 /**
109 * Constructor for a given output port.
110 *
111 * @param port the output port to set.
112 */
113 public ActionOutput(Port port) {
114 this.port = port;
115 this.maxLen = 0;
116 }
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700117
Ray Milkey269ffb92014-04-03 14:43:30 -0700118 /**
119 * Get the output port.
120 *
121 * @return the output port.
122 */
123 @JsonProperty("port")
124 public Port port() {
125 return this.port;
126 }
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800127
Ray Milkey269ffb92014-04-03 14:43:30 -0700128 /**
129 * Get the maximum length (in bytes) to send to controller if the
130 * port is set to PORT_CONTROLLER.
131 *
132 * @return the maximum length (in bytes) to send to controller if the
133 * port is set to PORT_CONTROLLER.
134 */
135 @JsonProperty("maxLen")
136 public short maxLen() {
137 return this.maxLen;
138 }
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800139
Ray Milkey269ffb92014-04-03 14:43:30 -0700140 /**
141 * Convert the action to a string.
142 * <p/>
143 * The string has the following form:
144 * [port=XXX maxLen=XXX]
145 *
146 * @return the action as a string.
147 */
148 @Override
149 public String toString() {
150 String ret = "[";
151 ret += "port=" + port.toString();
152 ret += " maxLen=" + maxLen;
153 ret += "]";
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800154
Ray Milkey269ffb92014-04-03 14:43:30 -0700155 return ret;
156 }
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -0700157
Ray Milkey269ffb92014-04-03 14:43:30 -0700158 /**
159 * Convert a string to an action.
160 * <p/>
161 * The string has the following form:
162 * [port=XXX maxLen=XXX]
163 *
164 * @param actionStr the action as a string.
165 */
166 public void fromString(String actionStr) {
167 String[] parts = actionStr.split(" ");
168 String decode = null;
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -0700169
Ray Milkey269ffb92014-04-03 14:43:30 -0700170 // Decode the "port=XXX" part
171 if (parts.length > 0)
172 decode = parts[0];
173 if (decode != null) {
174 String[] tokens = decode.split("port=");
175 if (tokens.length > 1 && tokens[1] != null) {
176 try {
177 Short valueShort = Short.valueOf(tokens[1]);
178 port = new Port(valueShort);
179 } catch (NumberFormatException e) {
180 throw new IllegalArgumentException("Invalid action string");
181 }
182 }
183 } else {
184 throw new IllegalArgumentException("Invalid action string");
185 }
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -0700186
Ray Milkey269ffb92014-04-03 14:43:30 -0700187 // Decode the "maxLen=XXX" part
188 decode = null;
189 if (parts.length > 1)
190 decode = parts[1];
191 if (decode != null) {
192 decode = decode.replace("]", "");
193 String[] tokens = decode.split("maxLen=");
194 if (tokens.length > 1 && tokens[1] != null) {
195 try {
196 maxLen = Short.valueOf(tokens[1]);
197 } catch (NumberFormatException e) {
198 throw new IllegalArgumentException("Invalid action string");
199 }
200 }
201 } else {
202 throw new IllegalArgumentException("Invalid action string");
203 }
204 }
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800205 }
206
207 /**
208 * Action structure for ACTION_SET_VLAN_VID: Set the 802.1q VLAN id
209 */
Yuta HIGUCHI382827f2013-10-14 16:06:43 -0700210 public static class ActionSetVlanId {
Ray Milkey269ffb92014-04-03 14:43:30 -0700211 private short vlanId; // The VLAN ID to set
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800212
Ray Milkey269ffb92014-04-03 14:43:30 -0700213 /**
214 * Default constructor.
215 */
216 public ActionSetVlanId() {
217 this.vlanId = 0;
218 }
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700219
Ray Milkey269ffb92014-04-03 14:43:30 -0700220 /**
221 * Copy constructor.
222 *
223 * @param other the object to copy from.
224 */
225 public ActionSetVlanId(ActionSetVlanId other) {
226 this.vlanId = other.vlanId;
227 }
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -0700228
Ray Milkey269ffb92014-04-03 14:43:30 -0700229 /**
230 * Constructor from a string.
231 * <p/>
232 * The string has the following form:
233 * [vlanId=XXX]
234 *
235 * @param actionStr the action as a string.
236 */
237 public ActionSetVlanId(String actionStr) {
238 this.fromString(actionStr);
239 }
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -0700240
Ray Milkey269ffb92014-04-03 14:43:30 -0700241 /**
242 * Constructor for a given VLAN ID.
243 *
244 * @param vlanId the VLAN ID to set.
245 */
246 public ActionSetVlanId(short vlanId) {
247 this.vlanId = vlanId;
248 }
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800249
Ray Milkey269ffb92014-04-03 14:43:30 -0700250 /**
251 * Get the VLAN ID.
252 *
253 * @return the VLAN ID.
254 */
255 @JsonProperty("vlanId")
256 public short vlanId() {
257 return this.vlanId;
258 }
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800259
Ray Milkey269ffb92014-04-03 14:43:30 -0700260 /**
261 * Convert the action to a string.
262 * <p/>
263 * The string has the following form:
264 * [vlanId=XXX]
265 *
266 * @return the action as a string.
267 */
268 @Override
269 public String toString() {
270 String ret = "[";
271 ret += "vlanId=" + this.vlanId;
272 ret += "]";
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800273
Ray Milkey269ffb92014-04-03 14:43:30 -0700274 return ret;
275 }
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -0700276
Ray Milkey269ffb92014-04-03 14:43:30 -0700277 /**
278 * Convert a string to an action.
279 * <p/>
280 * The string has the following form:
281 * [vlanId=XXX]
282 *
283 * @param actionStr the action as a string.
284 */
285 public void fromString(String actionStr) {
286 String[] parts = actionStr.split("vlanId=");
287 String decode = null;
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -0700288
Ray Milkey269ffb92014-04-03 14:43:30 -0700289 // Decode the value
290 if (parts.length > 1)
291 decode = parts[1];
292 if (decode != null) {
293 decode = decode.replace("]", "");
294 try {
295 vlanId = Short.valueOf(decode);
296 } catch (NumberFormatException e) {
297 throw new IllegalArgumentException("Invalid action string");
298 }
299 } else {
300 throw new IllegalArgumentException("Invalid action string");
301 }
302 }
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800303 }
304
305 /**
306 * Action structure for ACTION_SET_VLAN_PCP: Set the 802.1q priority
307 */
Yuta HIGUCHI382827f2013-10-14 16:06:43 -0700308 public static class ActionSetVlanPriority {
Ray Milkey269ffb92014-04-03 14:43:30 -0700309 private byte vlanPriority; // The VLAN priority to set
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800310
Ray Milkey269ffb92014-04-03 14:43:30 -0700311 /**
312 * Default constructor.
313 */
314 public ActionSetVlanPriority() {
315 this.vlanPriority = 0;
316 }
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700317
Ray Milkey269ffb92014-04-03 14:43:30 -0700318 /**
319 * Copy constructor.
320 *
321 * @param other the object to copy from.
322 */
323 public ActionSetVlanPriority(ActionSetVlanPriority other) {
324 this.vlanPriority = other.vlanPriority;
325 }
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -0700326
Ray Milkey269ffb92014-04-03 14:43:30 -0700327 /**
328 * Constructor from a string.
329 * <p/>
330 * The string has the following form:
331 * [vlanPriority=XXX]
332 *
333 * @param actionStr the action as a string.
334 */
335 public ActionSetVlanPriority(String actionStr) {
336 this.fromString(actionStr);
337 }
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -0700338
Ray Milkey269ffb92014-04-03 14:43:30 -0700339 /**
340 * Constructor for a given VLAN priority.
341 *
342 * @param vlanPriority the VLAN priority to set.
343 */
344 public ActionSetVlanPriority(byte vlanPriority) {
345 this.vlanPriority = vlanPriority;
346 }
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800347
Ray Milkey269ffb92014-04-03 14:43:30 -0700348 /**
349 * Get the VLAN priority.
350 *
351 * @return the VLAN priority.
352 */
353 @JsonProperty("vlanPriority")
354 public byte vlanPriority() {
355 return this.vlanPriority;
356 }
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800357
Ray Milkey269ffb92014-04-03 14:43:30 -0700358 /**
359 * Convert the action to a string.
360 * <p/>
361 * The string has the following form:
362 * [vlanPriority=XXX]
363 *
364 * @return the action as a string.
365 */
366 @Override
367 public String toString() {
368 String ret = "[";
369 ret += "vlanPriority=" + this.vlanPriority;
370 ret += "]";
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800371
Ray Milkey269ffb92014-04-03 14:43:30 -0700372 return ret;
373 }
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -0700374
Ray Milkey269ffb92014-04-03 14:43:30 -0700375 /**
376 * Convert a string to an action.
377 * <p/>
378 * The string has the following form:
379 * [vlanPriority=XXX]
380 *
381 * @param actionStr the action as a string.
382 */
383 public void fromString(String actionStr) {
384 String[] parts = actionStr.split("vlanPriority=");
385 String decode = null;
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -0700386
Ray Milkey269ffb92014-04-03 14:43:30 -0700387 // Decode the value
388 if (parts.length > 1)
389 decode = parts[1];
390 if (decode != null) {
391 decode = decode.replace("]", "");
392 try {
393 vlanPriority = Byte.valueOf(decode);
394 } catch (NumberFormatException e) {
395 throw new IllegalArgumentException("Invalid action string");
396 }
397 } else {
398 throw new IllegalArgumentException("Invalid action string");
399 }
400 }
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800401 }
402
403 /**
404 * Action structure for ACTION_STRIP_VLAN: Strip the 802.1q header
405 */
Yuta HIGUCHI382827f2013-10-14 16:06:43 -0700406 public static class ActionStripVlan {
Ray Milkey269ffb92014-04-03 14:43:30 -0700407 private boolean stripVlan; // If true, strip the VLAN header
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800408
Ray Milkey269ffb92014-04-03 14:43:30 -0700409 /**
410 * Default constructor.
411 */
412 public ActionStripVlan() {
413 this.stripVlan = false;
414 }
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700415
Ray Milkey269ffb92014-04-03 14:43:30 -0700416 /**
417 * Copy constructor.
418 *
419 * @param other the object to copy from.
420 */
421 public ActionStripVlan(ActionStripVlan other) {
422 this.stripVlan = other.stripVlan;
423 }
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -0700424
Ray Milkey269ffb92014-04-03 14:43:30 -0700425 /**
426 * Constructor from a string.
427 * <p/>
428 * The string has the following form:
429 * [stripVlan=XXX]
430 *
431 * @param actionStr the action as a string.
432 */
433 public ActionStripVlan(String actionStr) {
434 this.fromString(actionStr);
435 }
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -0700436
Ray Milkey269ffb92014-04-03 14:43:30 -0700437 /**
438 * Constructor for a given boolean flag.
439 *
440 * @param stripVlan if true, strip the VLAN header.
441 */
442 public ActionStripVlan(boolean stripVlan) {
443 this.stripVlan = stripVlan;
444 }
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800445
Ray Milkey269ffb92014-04-03 14:43:30 -0700446 /**
447 * Get the boolean flag whether the VLAN header should be stripped.
448 *
449 * @return the boolean flag whether the VLAN header should be stripped.
450 */
451 @JsonProperty("stripVlan")
452 public boolean stripVlan() {
453 return this.stripVlan;
454 }
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800455
Ray Milkey269ffb92014-04-03 14:43:30 -0700456 /**
457 * Convert the action to a string.
458 * <p/>
459 * The string has the following form:
460 * [stripVlan=XXX]
461 *
462 * @return the action as a string.
463 */
464 @Override
465 public String toString() {
466 String ret = "[";
467 ret += "stripVlan=" + this.stripVlan;
468 ret += "]";
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800469
Ray Milkey269ffb92014-04-03 14:43:30 -0700470 return ret;
471 }
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -0700472
Ray Milkey269ffb92014-04-03 14:43:30 -0700473 /**
474 * Convert a string to an action.
475 * <p/>
476 * The string has the following form:
477 * [stripVlan=XXX]
478 *
479 * @param actionStr the action as a string.
480 */
481 public void fromString(String actionStr) {
482 String[] parts = actionStr.split("stripVlan=");
483 String decode = null;
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -0700484
Ray Milkey269ffb92014-04-03 14:43:30 -0700485 // Decode the value
486 if (parts.length > 1)
487 decode = parts[1];
488 if (decode != null) {
489 decode = decode.replace("]", "");
490 stripVlan = Boolean.valueOf(decode);
491 } else {
492 throw new IllegalArgumentException("Invalid action string");
493 }
494 }
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800495 }
496
497 /**
498 * Action structure for ACTION_SET_DL_SRC and ACTION_SET_DL_DST:
499 * Set the Ethernet source/destination address.
500 */
Yuta HIGUCHI382827f2013-10-14 16:06:43 -0700501 public static class ActionSetEthernetAddr {
Ray Milkey269ffb92014-04-03 14:43:30 -0700502 private MACAddress addr; // The MAC address to set
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800503
Ray Milkey269ffb92014-04-03 14:43:30 -0700504 /**
505 * Default constructor.
506 */
507 public ActionSetEthernetAddr() {
508 this.addr = null;
509 }
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700510
Ray Milkey269ffb92014-04-03 14:43:30 -0700511 /**
512 * Copy constructor.
513 *
514 * @param other the object to copy from.
515 */
516 public ActionSetEthernetAddr(ActionSetEthernetAddr other) {
517 if (other.addr != null)
518 this.addr = MACAddress.valueOf(other.addr.toLong());
519 }
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -0700520
Ray Milkey269ffb92014-04-03 14:43:30 -0700521 /**
522 * Constructor from a string.
523 * <p/>
524 * The string has the following form:
525 * [addr=XXX]
526 *
527 * @param actionStr the action as a string.
528 */
529 public ActionSetEthernetAddr(String actionStr) {
530 this.fromString(actionStr);
531 }
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -0700532
Ray Milkey269ffb92014-04-03 14:43:30 -0700533 /**
534 * Constructor for a given MAC address.
535 *
536 * @param addr the MAC address to set.
537 */
538 public ActionSetEthernetAddr(MACAddress addr) {
539 this.addr = addr;
540 }
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800541
Ray Milkey269ffb92014-04-03 14:43:30 -0700542 /**
543 * Get the MAC address.
544 *
545 * @return the MAC address.
546 */
547 @JsonProperty("addr")
548 public MACAddress addr() {
549 return this.addr;
550 }
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800551
Ray Milkey269ffb92014-04-03 14:43:30 -0700552 /**
553 * Convert the action to a string.
554 * <p/>
555 * The string has the following form:
556 * [addr=XXX]
557 *
558 * @return the action as a string.
559 */
560 @Override
561 public String toString() {
562 String ret = "[";
563 ret += "addr=" + addr.toString();
564 ret += "]";
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800565
Ray Milkey269ffb92014-04-03 14:43:30 -0700566 return ret;
567 }
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -0700568
Ray Milkey269ffb92014-04-03 14:43:30 -0700569 /**
570 * Convert a string to an action.
571 * <p/>
572 * The string has the following form:
573 * [addr=XXX]
574 *
575 * @param actionStr the action as a string.
576 */
577 public void fromString(String actionStr) {
578 String[] parts = actionStr.split("addr=");
579 String decode = null;
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -0700580
Ray Milkey269ffb92014-04-03 14:43:30 -0700581 // Decode the value
582 if (parts.length > 1)
583 decode = parts[1];
584 if (decode != null) {
585 decode = decode.replace("]", "");
586 try {
587 addr = MACAddress.valueOf(decode);
588 } catch (IllegalArgumentException e) {
589 throw new IllegalArgumentException("Invalid action string");
590 }
591 } else {
592 throw new IllegalArgumentException("Invalid action string");
593 }
594 }
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800595 }
596
597 /**
598 * Action structure for ACTION_SET_NW_SRC and ACTION_SET_NW_DST:
599 * Set the IPv4 source/destination address.
600 */
Yuta HIGUCHI382827f2013-10-14 16:06:43 -0700601 public static class ActionSetIPv4Addr {
Ray Milkey269ffb92014-04-03 14:43:30 -0700602 private IPv4 addr; // The IPv4 address to set
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800603
Ray Milkey269ffb92014-04-03 14:43:30 -0700604 /**
605 * Default constructor.
606 */
607 public ActionSetIPv4Addr() {
608 this.addr = null;
609 }
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700610
Ray Milkey269ffb92014-04-03 14:43:30 -0700611 /**
612 * Copy constructor.
613 *
614 * @param other the object to copy from.
615 */
616 public ActionSetIPv4Addr(ActionSetIPv4Addr other) {
617 if (other.addr != null)
618 this.addr = new IPv4(other.addr);
619 }
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -0700620
Ray Milkey269ffb92014-04-03 14:43:30 -0700621 /**
622 * Constructor from a string.
623 * <p/>
624 * The string has the following form:
625 * [addr=XXX]
626 *
627 * @param actionStr the action as a string.
628 */
629 public ActionSetIPv4Addr(String actionStr) {
630 this.fromString(actionStr);
631 }
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -0700632
Ray Milkey269ffb92014-04-03 14:43:30 -0700633 /**
634 * Constructor for a given IPv4 address.
635 *
636 * @param addr the IPv4 address to set.
637 */
638 public ActionSetIPv4Addr(IPv4 addr) {
639 this.addr = addr;
640 }
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800641
Ray Milkey269ffb92014-04-03 14:43:30 -0700642 /**
643 * Get the IPv4 address.
644 *
645 * @return the IPv4 address.
646 */
647 @JsonProperty("addr")
648 public IPv4 addr() {
649 return this.addr;
650 }
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800651
Ray Milkey269ffb92014-04-03 14:43:30 -0700652 /**
653 * Convert the action to a string.
654 * <p/>
655 * The string has the following form:
656 * [addr=XXX]
657 *
658 * @return the action as a string.
659 */
660 @Override
661 public String toString() {
662 String ret = "[";
663 ret += "addr=" + addr.toString();
664 ret += "]";
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800665
Ray Milkey269ffb92014-04-03 14:43:30 -0700666 return ret;
667 }
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -0700668
Ray Milkey269ffb92014-04-03 14:43:30 -0700669 /**
670 * Convert a string to an action.
671 * <p/>
672 * The string has the following form:
673 * [addr=XXX]
674 *
675 * @param actionStr the action as a string.
676 */
677 public void fromString(String actionStr) {
678 String[] parts = actionStr.split("addr=");
679 String decode = null;
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -0700680
Ray Milkey269ffb92014-04-03 14:43:30 -0700681 // Decode the value
682 if (parts.length > 1)
683 decode = parts[1];
684 if (decode != null) {
685 decode = decode.replace("]", "");
686 try {
687 addr = new IPv4(decode);
688 } catch (IllegalArgumentException e) {
689 throw new IllegalArgumentException("Invalid action string");
690 }
691 } else {
692 throw new IllegalArgumentException("Invalid action string");
693 }
694 }
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800695 }
696
697 /**
698 * Action structure for ACTION_SET_NW_TOS:
699 * Set the IP ToS (DSCP field, 6 bits).
700 */
Yuta HIGUCHI382827f2013-10-14 16:06:43 -0700701 public static class ActionSetIpToS {
Ray Milkey269ffb92014-04-03 14:43:30 -0700702 private byte ipToS; // The IP ToS to set DSCP field, 6 bits)
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800703
Ray Milkey269ffb92014-04-03 14:43:30 -0700704 /**
705 * Default constructor.
706 */
707 public ActionSetIpToS() {
708 this.ipToS = 0;
709 }
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700710
Ray Milkey269ffb92014-04-03 14:43:30 -0700711 /**
712 * Copy constructor.
713 *
714 * @param other the object to copy from.
715 */
716 public ActionSetIpToS(ActionSetIpToS other) {
717 this.ipToS = other.ipToS;
718 }
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -0700719
Ray Milkey269ffb92014-04-03 14:43:30 -0700720 /**
721 * Constructor from a string.
722 * <p/>
723 * The string has the following form:
724 * [ipToS=XXX]
725 *
726 * @param actionStr the action as a string.
727 */
728 public ActionSetIpToS(String actionStr) {
729 this.fromString(actionStr);
730 }
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -0700731
Ray Milkey269ffb92014-04-03 14:43:30 -0700732 /**
733 * Constructor for a given IP ToS (DSCP field, 6 bits).
734 *
735 * @param ipToS the IP ToS (DSCP field, 6 bits) to set.
736 */
737 public ActionSetIpToS(byte ipToS) {
738 this.ipToS = ipToS;
739 }
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800740
Ray Milkey269ffb92014-04-03 14:43:30 -0700741 /**
742 * Get the IP ToS (DSCP field, 6 bits).
743 *
744 * @return the IP ToS (DSCP field, 6 bits).
745 */
746 @JsonProperty("ipToS")
747 public byte ipToS() {
748 return this.ipToS;
749 }
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800750
Ray Milkey269ffb92014-04-03 14:43:30 -0700751 /**
752 * Convert the action to a string.
753 * <p/>
754 * The string has the following form:
755 * [ipToS=XXX]
756 *
757 * @return the action as a string.
758 */
759 @Override
760 public String toString() {
761 String ret = "[";
762 ret += "ipToS=" + ipToS;
763 ret += "]";
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800764
Ray Milkey269ffb92014-04-03 14:43:30 -0700765 return ret;
766 }
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -0700767
Ray Milkey269ffb92014-04-03 14:43:30 -0700768 /**
769 * Convert a string to an action.
770 * <p/>
771 * The string has the following form:
772 * [ipToS=XXX]
773 *
774 * @param actionStr the action as a string.
775 */
776 public void fromString(String actionStr) {
777 String[] parts = actionStr.split("ipToS=");
778 String decode = null;
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -0700779
Ray Milkey269ffb92014-04-03 14:43:30 -0700780 // Decode the value
781 if (parts.length > 1)
782 decode = parts[1];
783 if (decode != null) {
784 decode = decode.replace("]", "");
785 try {
786 ipToS = Byte.valueOf(decode);
787 } catch (NumberFormatException e) {
788 throw new IllegalArgumentException("Invalid action string");
789 }
790 } else {
791 throw new IllegalArgumentException("Invalid action string");
792 }
793 }
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800794 }
795
796 /**
797 * Action structure for ACTION_SET_TP_SRC and ACTION_SET_TP_DST:
798 * Set the TCP/UDP source/destination port.
799 */
Yuta HIGUCHI382827f2013-10-14 16:06:43 -0700800 public static class ActionSetTcpUdpPort {
Ray Milkey269ffb92014-04-03 14:43:30 -0700801 private short port; // The TCP/UDP port to set
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800802
Ray Milkey269ffb92014-04-03 14:43:30 -0700803 /**
804 * Default constructor.
805 */
806 public ActionSetTcpUdpPort() {
807 this.port = 0;
808 }
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700809
Ray Milkey269ffb92014-04-03 14:43:30 -0700810 /**
811 * Copy constructor.
812 *
813 * @param other the object to copy from.
814 */
815 public ActionSetTcpUdpPort(ActionSetTcpUdpPort other) {
816 this.port = other.port;
817 }
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -0700818
Ray Milkey269ffb92014-04-03 14:43:30 -0700819 /**
820 * Constructor from a string.
821 * <p/>
822 * The string has the following form:
823 * [port=XXX]
824 *
825 * @param actionStr the action as a string.
826 */
827 public ActionSetTcpUdpPort(String actionStr) {
828 this.fromString(actionStr);
829 }
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -0700830
Ray Milkey269ffb92014-04-03 14:43:30 -0700831 /**
832 * Constructor for a given TCP/UDP port.
833 *
834 * @param port the TCP/UDP port to set.
835 */
836 public ActionSetTcpUdpPort(short port) {
837 this.port = port;
838 }
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800839
Ray Milkey269ffb92014-04-03 14:43:30 -0700840 /**
841 * Get the TCP/UDP port.
842 *
843 * @return the TCP/UDP port.
844 */
845 @JsonProperty("port")
846 public short port() {
847 return this.port;
848 }
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800849
Ray Milkey269ffb92014-04-03 14:43:30 -0700850 /**
851 * Convert the action to a string.
852 * <p/>
853 * The string has the following form:
854 * [port=XXX]
855 *
856 * @return the action as a string.
857 */
858 @Override
859 public String toString() {
860 String ret = "[";
861 ret += "port=" + port;
862 ret += "]";
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800863
Ray Milkey269ffb92014-04-03 14:43:30 -0700864 return ret;
865 }
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -0700866
Ray Milkey269ffb92014-04-03 14:43:30 -0700867 /**
868 * Convert a string to an action.
869 * <p/>
870 * The string has the following form:
871 * [port=XXX]
872 *
873 * @param actionStr the action as a string.
874 */
875 public void fromString(String actionStr) {
876 String[] parts = actionStr.split("port=");
877 String decode = null;
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -0700878
Ray Milkey269ffb92014-04-03 14:43:30 -0700879 // Decode the value
880 if (parts.length > 1)
881 decode = parts[1];
882 if (decode != null) {
883 decode = decode.replace("]", "");
884 try {
885 port = Short.valueOf(decode);
886 } catch (NumberFormatException e) {
887 throw new IllegalArgumentException("Invalid action string");
888 }
889 } else {
890 throw new IllegalArgumentException("Invalid action string");
891 }
892 }
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800893 }
894
895 /**
896 * Action structure for ACTION_ENQUEUE: Output to queue on port.
897 */
Yuta HIGUCHI382827f2013-10-14 16:06:43 -0700898 public static class ActionEnqueue {
Ray Milkey269ffb92014-04-03 14:43:30 -0700899 private Port port; // Port that queue belongs. Should
900 // refer to a valid physical port
901 // (i.e. < PORT_MAX) or PORT_IN_PORT
902 private int queueId; // Where to enqueue the packets
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800903
Ray Milkey269ffb92014-04-03 14:43:30 -0700904 /**
905 * Default constructor.
906 */
907 public ActionEnqueue() {
908 this.port = null;
909 this.queueId = 0;
910 }
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -0700911
Ray Milkey269ffb92014-04-03 14:43:30 -0700912 /**
913 * Copy constructor.
914 *
915 * @param other the object to copy from.
916 */
917 public ActionEnqueue(ActionEnqueue other) {
918 if (other.port != null)
919 this.port = new Port(other.port);
920 this.queueId = other.queueId;
921 }
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -0700922
Ray Milkey269ffb92014-04-03 14:43:30 -0700923 /**
924 * Constructor from a string.
925 * <p/>
926 * The string has the following form:
927 * [port=XXX queueId=XXX]
928 *
929 * @param actionStr the action as a string.
930 */
931 public ActionEnqueue(String actionStr) {
932 this.fromString(actionStr);
933 }
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -0700934
Ray Milkey269ffb92014-04-03 14:43:30 -0700935 /**
936 * Constructor for a given port and queue ID.
937 *
938 * @param port the port to set.
939 * @param queueId the queue ID on the port.
940 */
941 public ActionEnqueue(Port port, int queueId) {
942 this.port = port;
943 this.queueId = queueId;
944 }
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800945
Ray Milkey269ffb92014-04-03 14:43:30 -0700946 /**
947 * Get the port.
948 *
949 * @return the port.
950 */
951 @JsonProperty("port")
952 public Port port() {
953 return this.port;
954 }
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800955
Ray Milkey269ffb92014-04-03 14:43:30 -0700956 /**
957 * Get the queue ID.
958 *
959 * @return the queue ID.
960 */
961 @JsonProperty("queueId")
962 public int queueId() {
963 return this.queueId;
964 }
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800965
Ray Milkey269ffb92014-04-03 14:43:30 -0700966 /**
967 * Convert the action to a string.
968 * <p/>
969 * The string has the following form:
970 * [port=XXX queueId=XXX]
971 *
972 * @return the action as a string.
973 */
974 @Override
975 public String toString() {
976 String ret = "[";
977 ret += "port=" + port.toString();
978 ret += " queueId=" + queueId;
979 ret += "]";
Pavlin Radoslavovede97582013-03-08 18:57:28 -0800980
Ray Milkey269ffb92014-04-03 14:43:30 -0700981 return ret;
982 }
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -0700983
Ray Milkey269ffb92014-04-03 14:43:30 -0700984 /**
985 * Convert a string to an action.
986 * <p/>
987 * The string has the following form:
988 * [port=XXX queueId=XXX]
989 *
990 * @param actionStr the action as a string.
991 */
992 public void fromString(String actionStr) {
993 String[] parts = actionStr.split(" ");
994 String decode = null;
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -0700995
Ray Milkey269ffb92014-04-03 14:43:30 -0700996 // Decode the "port=XXX" part
997 if (parts.length > 0)
998 decode = parts[0];
999 if (decode != null) {
1000 String[] tokens = decode.split("port=");
1001 if (tokens.length > 1 && tokens[1] != null) {
1002 try {
1003 Short valueShort = Short.valueOf(tokens[1]);
1004 port = new Port(valueShort);
1005 } catch (NumberFormatException e) {
1006 throw new IllegalArgumentException("Invalid action string");
1007 }
1008 }
1009 } else {
1010 throw new IllegalArgumentException("Invalid action string");
1011 }
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -07001012
Ray Milkey269ffb92014-04-03 14:43:30 -07001013 // Decode the "queueId=XXX" part
1014 decode = null;
1015 if (parts.length > 1)
1016 decode = parts[1];
1017 if (decode != null) {
1018 decode = decode.replace("]", "");
1019 String[] tokens = decode.split("queueId=");
1020 if (tokens.length > 1 && tokens[1] != null) {
1021 try {
1022 queueId = Short.valueOf(tokens[1]);
1023 } catch (NumberFormatException e) {
1024 throw new IllegalArgumentException("Invalid action string");
1025 }
1026 }
1027 } else {
1028 throw new IllegalArgumentException("Invalid action string");
1029 }
1030 }
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001031 }
1032
Ray Milkey269ffb92014-04-03 14:43:30 -07001033 private ActionValues actionType; // The action type
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001034
1035 //
1036 // The actions.
1037 // NOTE: Only one action should be set.
1038 //
1039 private ActionOutput actionOutput;
1040 private ActionSetVlanId actionSetVlanId;
1041 private ActionSetVlanPriority actionSetVlanPriority;
1042 private ActionStripVlan actionStripVlan;
1043 private ActionSetEthernetAddr actionSetEthernetSrcAddr;
1044 private ActionSetEthernetAddr actionSetEthernetDstAddr;
1045 private ActionSetIPv4Addr actionSetIPv4SrcAddr;
1046 private ActionSetIPv4Addr actionSetIPv4DstAddr;
1047 private ActionSetIpToS actionSetIpToS;
1048 private ActionSetTcpUdpPort actionSetTcpUdpSrcPort;
1049 private ActionSetTcpUdpPort actionSetTcpUdpDstPort;
1050 private ActionEnqueue actionEnqueue;
1051
1052 /**
1053 * Default constructor.
1054 */
1055 public FlowEntryAction() {
Ray Milkey269ffb92014-04-03 14:43:30 -07001056 actionType = ActionValues.ACTION_VENDOR; // XXX: Initial value
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001057 }
1058
1059 /**
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -07001060 * Copy constructor.
1061 *
1062 * @param other the object to copy from.
1063 */
1064 public FlowEntryAction(FlowEntryAction other) {
Ray Milkey269ffb92014-04-03 14:43:30 -07001065 this.actionType = other.actionType;
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -07001066
Ray Milkey269ffb92014-04-03 14:43:30 -07001067 //
1068 if (other.actionOutput != null)
1069 this.actionOutput = new ActionOutput(other.actionOutput);
1070 else
1071 this.actionOutput = null;
1072 //
1073 if (other.actionSetVlanId != null)
1074 this.actionSetVlanId = new ActionSetVlanId(other.actionSetVlanId);
1075 else
1076 this.actionSetVlanId = null;
1077 //
1078 if (other.actionSetVlanPriority != null)
1079 this.actionSetVlanPriority = new ActionSetVlanPriority(other.actionSetVlanPriority);
1080 else
1081 this.actionSetVlanPriority = null;
1082 //
1083 if (other.actionStripVlan != null)
1084 this.actionStripVlan = new ActionStripVlan(other.actionStripVlan);
1085 else
1086 this.actionStripVlan = null;
1087 //
1088 if (other.actionSetEthernetSrcAddr != null)
1089 this.actionSetEthernetSrcAddr = new ActionSetEthernetAddr(other.actionSetEthernetSrcAddr);
1090 else
1091 this.actionSetEthernetSrcAddr = null;
1092 //
1093 if (other.actionSetEthernetDstAddr != null)
1094 this.actionSetEthernetDstAddr = new ActionSetEthernetAddr(other.actionSetEthernetDstAddr);
1095 else
1096 this.actionSetEthernetDstAddr = null;
1097 //
1098 if (other.actionSetIPv4SrcAddr != null)
1099 this.actionSetIPv4SrcAddr = new ActionSetIPv4Addr(other.actionSetIPv4SrcAddr);
1100 else
1101 this.actionSetIPv4SrcAddr = null;
1102 //
1103 if (other.actionSetIPv4DstAddr != null)
1104 this.actionSetIPv4DstAddr = new ActionSetIPv4Addr(other.actionSetIPv4DstAddr);
1105 else
1106 this.actionSetIPv4DstAddr = null;
1107 //
1108 if (other.actionSetIpToS != null)
1109 this.actionSetIpToS = new ActionSetIpToS(other.actionSetIpToS);
1110 else
1111 this.actionSetIpToS = null;
1112 //
1113 if (other.actionSetTcpUdpSrcPort != null)
1114 this.actionSetTcpUdpSrcPort = new ActionSetTcpUdpPort(other.actionSetTcpUdpSrcPort);
1115 else
1116 this.actionSetTcpUdpSrcPort = null;
1117 //
1118 if (other.actionSetTcpUdpDstPort != null)
1119 this.actionSetTcpUdpDstPort = new ActionSetTcpUdpPort(other.actionSetTcpUdpDstPort);
1120 else
1121 this.actionSetTcpUdpDstPort = null;
1122 //
1123 if (other.actionEnqueue != null)
1124 this.actionEnqueue = new ActionEnqueue(other.actionEnqueue);
1125 else
1126 this.actionEnqueue = null;
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -07001127 }
1128
1129 /**
1130 * Constructor from a string.
Ray Milkey269ffb92014-04-03 14:43:30 -07001131 * <p/>
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -07001132 * The string has the following form:
Ray Milkey269ffb92014-04-03 14:43:30 -07001133 * [type=XXX action=XXX]
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -07001134 *
1135 * @param actionStr the action as a string.
1136 */
1137 public FlowEntryAction(String actionStr) {
Ray Milkey269ffb92014-04-03 14:43:30 -07001138 this.fromString(actionStr);
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -07001139 }
1140
1141 /**
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001142 * Get the action type.
1143 *
1144 * @return the action type.
1145 */
1146 @JsonProperty("actionType")
Ray Milkey269ffb92014-04-03 14:43:30 -07001147 public ActionValues actionType() {
1148 return actionType;
1149 }
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001150
1151 /**
1152 * Get the output action.
1153 *
1154 * @return the output action.
1155 */
1156 @JsonProperty("actionOutput")
Ray Milkey269ffb92014-04-03 14:43:30 -07001157 public ActionOutput actionOutput() {
1158 return actionOutput;
1159 }
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001160
1161 /**
1162 * Set the output action on a port.
1163 *
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -07001164 * @param action the action to set.
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001165 */
1166 @JsonProperty("actionOutput")
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -07001167 public void setActionOutput(ActionOutput action) {
Ray Milkey269ffb92014-04-03 14:43:30 -07001168 actionOutput = action;
1169 actionType = ActionValues.ACTION_OUTPUT;
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -07001170 }
1171
1172 /**
1173 * Set the output action on a port.
1174 *
1175 * @param port the output port to set.
1176 */
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001177 public void setActionOutput(Port port) {
Ray Milkey269ffb92014-04-03 14:43:30 -07001178 actionOutput = new ActionOutput(port);
1179 actionType = ActionValues.ACTION_OUTPUT;
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001180 }
1181
1182 /**
1183 * Set the output action to controller.
1184 *
1185 * @param maxLen the maximum length (in bytes) to send to controller.
1186 */
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001187 public void setActionOutputToController(short maxLen) {
Ray Milkey269ffb92014-04-03 14:43:30 -07001188 Port port = new Port(Port.PortValues.PORT_CONTROLLER);
1189 actionOutput = new ActionOutput(port, maxLen);
1190 actionType = ActionValues.ACTION_OUTPUT;
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001191 }
1192
1193 /**
1194 * Get the action to set the VLAN ID.
1195 *
1196 * @return the action to set the VLAN ID.
1197 */
1198 @JsonProperty("actionSetVlanId")
Ray Milkey269ffb92014-04-03 14:43:30 -07001199 public ActionSetVlanId actionSetVlanId() {
1200 return actionSetVlanId;
1201 }
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001202
1203 /**
1204 * Set the action to set the VLAN ID.
1205 *
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -07001206 * @param action the action to set.
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001207 */
1208 @JsonProperty("actionSetVlanId")
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -07001209 public void setActionSetVlanId(ActionSetVlanId action) {
Ray Milkey269ffb92014-04-03 14:43:30 -07001210 actionSetVlanId = action;
1211 actionType = ActionValues.ACTION_SET_VLAN_VID;
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -07001212 }
1213
1214 /**
1215 * Set the action to set the VLAN ID.
1216 *
1217 * @param vlanId the VLAN ID to set.
1218 */
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001219 public void setActionSetVlanId(short vlanId) {
Ray Milkey269ffb92014-04-03 14:43:30 -07001220 actionSetVlanId = new ActionSetVlanId(vlanId);
1221 actionType = ActionValues.ACTION_SET_VLAN_VID;
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001222 }
1223
1224 /**
1225 * Get the action to set the VLAN priority.
1226 *
1227 * @return the action to set the VLAN priority.
1228 */
1229 @JsonProperty("actionSetVlanPriority")
1230 public ActionSetVlanPriority actionSetVlanPriority() {
Ray Milkey269ffb92014-04-03 14:43:30 -07001231 return actionSetVlanPriority;
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001232 }
1233
1234 /**
1235 * Set the action to set the VLAN priority.
1236 *
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -07001237 * @param action the action to set.
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001238 */
1239 @JsonProperty("actionSetVlanPriority")
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -07001240 public void setActionSetVlanPriority(ActionSetVlanPriority action) {
Ray Milkey269ffb92014-04-03 14:43:30 -07001241 actionSetVlanPriority = action;
1242 actionType = ActionValues.ACTION_SET_VLAN_PCP;
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -07001243 }
1244
1245 /**
1246 * Set the action to set the VLAN priority.
1247 *
1248 * @param vlanPriority the VLAN priority to set.
1249 */
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001250 public void setActionSetVlanPriority(byte vlanPriority) {
Ray Milkey269ffb92014-04-03 14:43:30 -07001251 actionSetVlanPriority = new ActionSetVlanPriority(vlanPriority);
1252 actionType = ActionValues.ACTION_SET_VLAN_PCP;
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001253 }
1254
1255 /**
1256 * Get the action to strip the VLAN header.
1257 *
1258 * @return the action to strip the VLAN header.
1259 */
1260 @JsonProperty("actionStripVlan")
1261 public ActionStripVlan actionStripVlan() {
Ray Milkey269ffb92014-04-03 14:43:30 -07001262 return actionStripVlan;
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001263 }
1264
1265 /**
1266 * Set the action to strip the VLAN header.
1267 *
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -07001268 * @param action the action to set.
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001269 */
1270 @JsonProperty("actionStripVlan")
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -07001271 public void setActionStripVlan(ActionStripVlan action) {
Ray Milkey269ffb92014-04-03 14:43:30 -07001272 actionStripVlan = action;
1273 actionType = ActionValues.ACTION_STRIP_VLAN;
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -07001274 }
1275
1276 /**
1277 * Set the action to strip the VLAN header.
1278 *
1279 * @param stripVlan if true, strip the VLAN header.
1280 */
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001281 public void setActionStripVlan(boolean stripVlan) {
Ray Milkey269ffb92014-04-03 14:43:30 -07001282 actionStripVlan = new ActionStripVlan(stripVlan);
1283 actionType = ActionValues.ACTION_STRIP_VLAN;
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001284 }
1285
1286 /**
1287 * Get the action to set the Ethernet source address.
1288 *
1289 * @return the action to set the Ethernet source address.
1290 */
1291 @JsonProperty("actionSetEthernetSrcAddr")
1292 public ActionSetEthernetAddr actionSetEthernetSrcAddr() {
Ray Milkey269ffb92014-04-03 14:43:30 -07001293 return actionSetEthernetSrcAddr;
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001294 }
1295
1296 /**
1297 * Set the action to set the Ethernet source address.
1298 *
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -07001299 * @param action the action to set.
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001300 */
1301 @JsonProperty("actionSetEthernetSrcAddr")
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -07001302 public void setActionSetEthernetSrcAddr(ActionSetEthernetAddr action) {
Ray Milkey269ffb92014-04-03 14:43:30 -07001303 actionSetEthernetSrcAddr = action;
1304 actionType = ActionValues.ACTION_SET_DL_SRC;
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -07001305 }
1306
1307 /**
1308 * Set the action to set the Ethernet source address.
1309 *
1310 * @param addr the MAC address to set as the Ethernet source address.
1311 */
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001312 public void setActionSetEthernetSrcAddr(MACAddress addr) {
Ray Milkey269ffb92014-04-03 14:43:30 -07001313 actionSetEthernetSrcAddr = new ActionSetEthernetAddr(addr);
1314 actionType = ActionValues.ACTION_SET_DL_SRC;
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001315 }
1316
1317 /**
1318 * Get the action to set the Ethernet destination address.
1319 *
1320 * @return the action to set the Ethernet destination address.
1321 */
1322 @JsonProperty("actionSetEthernetDstAddr")
1323 public ActionSetEthernetAddr actionSetEthernetDstAddr() {
Ray Milkey269ffb92014-04-03 14:43:30 -07001324 return actionSetEthernetDstAddr;
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001325 }
1326
1327 /**
1328 * Set the action to set the Ethernet destination address.
1329 *
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -07001330 * @param action the action to set.
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001331 */
1332 @JsonProperty("actionSetEthernetDstAddr")
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -07001333 public void setActionSetEthernetDstAddr(ActionSetEthernetAddr action) {
Ray Milkey269ffb92014-04-03 14:43:30 -07001334 actionSetEthernetDstAddr = action;
1335 actionType = ActionValues.ACTION_SET_DL_DST;
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -07001336 }
1337
1338 /**
1339 * Set the action to set the Ethernet destination address.
1340 *
1341 * @param addr the MAC address to set as the Ethernet destination address.
1342 */
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001343 public void setActionSetEthernetDstAddr(MACAddress addr) {
Ray Milkey269ffb92014-04-03 14:43:30 -07001344 actionSetEthernetDstAddr = new ActionSetEthernetAddr(addr);
1345 actionType = ActionValues.ACTION_SET_DL_DST;
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001346 }
1347
1348 /**
1349 * Get the action to set the IPv4 source address.
1350 *
1351 * @return the action to set the IPv4 source address.
1352 */
1353 @JsonProperty("actionSetIPv4SrcAddr")
1354 public ActionSetIPv4Addr actionSetIPv4SrcAddr() {
Ray Milkey269ffb92014-04-03 14:43:30 -07001355 return actionSetIPv4SrcAddr;
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001356 }
1357
1358 /**
1359 * Set the action to set the IPv4 source address.
1360 *
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -07001361 * @param action the action to set.
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001362 */
1363 @JsonProperty("actionSetIPv4SrcAddr")
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -07001364 public void setActionSetIPv4SrcAddr(ActionSetIPv4Addr action) {
Ray Milkey269ffb92014-04-03 14:43:30 -07001365 actionSetIPv4SrcAddr = action;
1366 actionType = ActionValues.ACTION_SET_NW_SRC;
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -07001367 }
1368
1369 /**
1370 * Set the action to set the IPv4 source address.
1371 *
1372 * @param addr the IPv4 address to set as the IPv4 source address.
1373 */
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001374 public void setActionSetIPv4SrcAddr(IPv4 addr) {
Ray Milkey269ffb92014-04-03 14:43:30 -07001375 actionSetIPv4SrcAddr = new ActionSetIPv4Addr(addr);
1376 actionType = ActionValues.ACTION_SET_NW_SRC;
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001377 }
1378
1379 /**
1380 * Get the action to set the IPv4 destination address.
1381 *
1382 * @return the action to set the IPv4 destination address.
1383 */
1384 @JsonProperty("actionSetIPv4DstAddr")
1385 public ActionSetIPv4Addr actionSetIPv4DstAddr() {
Ray Milkey269ffb92014-04-03 14:43:30 -07001386 return actionSetIPv4DstAddr;
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001387 }
1388
1389 /**
1390 * Set the action to set the IPv4 destination address.
1391 *
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -07001392 * @param action the action to set.
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001393 */
1394 @JsonProperty("actionSetIPv4DstAddr")
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -07001395 public void setActionSetIPv4DstAddr(ActionSetIPv4Addr action) {
Ray Milkey269ffb92014-04-03 14:43:30 -07001396 actionSetIPv4DstAddr = action;
1397 actionType = ActionValues.ACTION_SET_NW_DST;
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -07001398 }
1399
1400 /**
1401 * Set the action to set the IPv4 destination address.
1402 *
1403 * @param addr the IPv4 address to set as the IPv4 destination address.
1404 */
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001405 public void setActionSetIPv4DstAddr(IPv4 addr) {
Ray Milkey269ffb92014-04-03 14:43:30 -07001406 actionSetIPv4DstAddr = new ActionSetIPv4Addr(addr);
1407 actionType = ActionValues.ACTION_SET_NW_DST;
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001408 }
1409
1410 /**
1411 * Get the action to set the IP ToS (DSCP field, 6 bits).
1412 *
1413 * @return the action to set the IP ToS (DSCP field, 6 bits).
1414 */
1415 @JsonProperty("actionSetIpToS")
1416 public ActionSetIpToS actionSetIpToS() {
Ray Milkey269ffb92014-04-03 14:43:30 -07001417 return actionSetIpToS;
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001418 }
1419
1420 /**
1421 * Set the action to set the IP ToS (DSCP field, 6 bits).
1422 *
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -07001423 * @param action the action to set.
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001424 */
1425 @JsonProperty("actionSetIpToS")
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -07001426 public void setActionSetIpToS(ActionSetIpToS action) {
Ray Milkey269ffb92014-04-03 14:43:30 -07001427 actionSetIpToS = action;
1428 actionType = ActionValues.ACTION_SET_NW_TOS;
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -07001429 }
1430
1431 /**
1432 * Set the action to set the IP ToS (DSCP field, 6 bits).
1433 *
1434 * @param ipToS the IP ToS (DSCP field, 6 bits) to set.
1435 */
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001436 public void setActionSetIpToS(byte ipToS) {
Ray Milkey269ffb92014-04-03 14:43:30 -07001437 actionSetIpToS = new ActionSetIpToS(ipToS);
1438 actionType = ActionValues.ACTION_SET_NW_TOS;
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001439 }
1440
1441 /**
1442 * Get the action to set the TCP/UDP source port.
1443 *
1444 * @return the action to set the TCP/UDP source port.
1445 */
1446 @JsonProperty("actionSetTcpUdpSrcPort")
1447 public ActionSetTcpUdpPort actionSetTcpUdpSrcPort() {
Ray Milkey269ffb92014-04-03 14:43:30 -07001448 return actionSetTcpUdpSrcPort;
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001449 }
1450
1451 /**
1452 * Set the action to set the TCP/UDP source port.
1453 *
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -07001454 * @param action the action to set.
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001455 */
1456 @JsonProperty("actionSetTcpUdpSrcPort")
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -07001457 public void setActionSetTcpUdpSrcPort(ActionSetTcpUdpPort action) {
Ray Milkey269ffb92014-04-03 14:43:30 -07001458 actionSetTcpUdpSrcPort = action;
1459 actionType = ActionValues.ACTION_SET_TP_SRC;
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -07001460 }
1461
1462 /**
1463 * Set the action to set the TCP/UDP source port.
1464 *
1465 * @param port the TCP/UDP port to set as the TCP/UDP source port.
1466 */
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001467 public void setActionSetTcpUdpSrcPort(short port) {
Ray Milkey269ffb92014-04-03 14:43:30 -07001468 actionSetTcpUdpSrcPort = new ActionSetTcpUdpPort(port);
1469 actionType = ActionValues.ACTION_SET_TP_SRC;
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001470 }
1471
1472 /**
1473 * Get the action to set the TCP/UDP destination port.
1474 *
1475 * @return the action to set the TCP/UDP destination port.
1476 */
1477 @JsonProperty("actionSetTcpUdpDstPort")
1478 public ActionSetTcpUdpPort actionSetTcpUdpDstPort() {
Ray Milkey269ffb92014-04-03 14:43:30 -07001479 return actionSetTcpUdpDstPort;
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001480 }
1481
1482 /**
1483 * Set the action to set the TCP/UDP destination port.
1484 *
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -07001485 * @param action the action to set.
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001486 */
1487 @JsonProperty("actionSetTcpUdpDstPort")
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -07001488 public void setActionSetTcpUdpDstPort(ActionSetTcpUdpPort action) {
Ray Milkey269ffb92014-04-03 14:43:30 -07001489 actionSetTcpUdpDstPort = action;
1490 actionType = ActionValues.ACTION_SET_TP_DST;
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -07001491 }
1492
1493 /**
1494 * Set the action to set the TCP/UDP destination port.
1495 *
1496 * @param port the TCP/UDP port to set as the TCP/UDP destination port.
1497 */
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001498 public void setActionSetTcpUdpDstPort(short port) {
Ray Milkey269ffb92014-04-03 14:43:30 -07001499 actionSetTcpUdpDstPort = new ActionSetTcpUdpPort(port);
1500 actionType = ActionValues.ACTION_SET_TP_DST;
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001501 }
1502
1503 /**
1504 * Get the action to output to queue on a port.
1505 *
1506 * @return the action to output to queue on a port.
1507 */
1508 @JsonProperty("actionEnqueue")
Ray Milkey269ffb92014-04-03 14:43:30 -07001509 public ActionEnqueue actionEnqueue() {
1510 return actionEnqueue;
1511 }
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001512
1513 /**
1514 * Set the action to output to queue on a port.
1515 *
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -07001516 * @param action the action to set.
1517 */
1518 @JsonProperty("actionEnqueue")
1519 public void setActionEnqueue(ActionEnqueue action) {
Ray Milkey269ffb92014-04-03 14:43:30 -07001520 actionEnqueue = action;
1521 actionType = ActionValues.ACTION_ENQUEUE;
Pavlin Radoslavovf13923a2013-03-11 19:42:17 -07001522 }
1523
1524 /**
1525 * Set the action to output to queue on a port.
1526 *
Ray Milkey269ffb92014-04-03 14:43:30 -07001527 * @param port the port to set.
HIGUCHI Yutaeb567aa2013-10-08 19:27:35 -07001528 * @param queueId the queue ID to set.
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001529 */
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001530 public void setActionEnqueue(Port port, int queueId) {
Ray Milkey269ffb92014-04-03 14:43:30 -07001531 actionEnqueue = new ActionEnqueue(port, queueId);
1532 actionType = ActionValues.ACTION_ENQUEUE;
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001533 }
1534
1535 /**
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -07001536 * Convert the action to a string.
Ray Milkey269ffb92014-04-03 14:43:30 -07001537 * <p/>
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001538 * The string has the following form:
Ray Milkey269ffb92014-04-03 14:43:30 -07001539 * [type=XXX action=XXX]
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001540 *
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -07001541 * @return the action as a string.
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001542 */
1543 @Override
1544 public String toString() {
Ray Milkey269ffb92014-04-03 14:43:30 -07001545 String ret = "[";
1546 ret += "type=" + actionType;
1547 switch (actionType) {
1548 case ACTION_OUTPUT:
1549 ret += " action=" + actionOutput.toString();
1550 break;
1551 case ACTION_SET_VLAN_VID:
1552 ret += " action=" + actionSetVlanId.toString();
1553 break;
1554 case ACTION_SET_VLAN_PCP:
1555 ret += " action=" + actionSetVlanPriority.toString();
1556 break;
1557 case ACTION_STRIP_VLAN:
1558 ret += " action=" + actionStripVlan.toString();
1559 break;
1560 case ACTION_SET_DL_SRC:
1561 ret += " action=" + actionSetEthernetSrcAddr.toString();
1562 break;
1563 case ACTION_SET_DL_DST:
1564 ret += " action=" + actionSetEthernetDstAddr.toString();
1565 break;
1566 case ACTION_SET_NW_SRC:
1567 ret += " action=" + actionSetIPv4SrcAddr.toString();
1568 break;
1569 case ACTION_SET_NW_DST:
1570 ret += " action=" + actionSetIPv4DstAddr.toString();
1571 break;
1572 case ACTION_SET_NW_TOS:
1573 ret += " action=" + actionSetIpToS.toString();
1574 break;
1575 case ACTION_SET_TP_SRC:
1576 ret += " action=" + actionSetTcpUdpSrcPort.toString();
1577 break;
1578 case ACTION_SET_TP_DST:
1579 ret += " action=" + actionSetTcpUdpDstPort.toString();
1580 break;
1581 case ACTION_ENQUEUE:
1582 ret += " action=" + actionEnqueue.toString();
1583 break;
1584 case ACTION_VENDOR:
1585 ret += " action=VENDOR";
1586 break;
1587 }
1588 ret += "]";
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001589
Ray Milkey269ffb92014-04-03 14:43:30 -07001590 return ret;
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001591 }
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -07001592
1593 /**
1594 * Convert a string to an action.
Ray Milkey269ffb92014-04-03 14:43:30 -07001595 * <p/>
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -07001596 * The string has the following form:
Ray Milkey269ffb92014-04-03 14:43:30 -07001597 * [type=XXX action=XXX]
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -07001598 *
1599 * @param actionStr the action as a string.
1600 */
1601 public void fromString(String actionStr) {
Ray Milkey269ffb92014-04-03 14:43:30 -07001602 String[] parts = actionStr.split("type=");
1603 String decode = null;
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -07001604
Ray Milkey269ffb92014-04-03 14:43:30 -07001605 // Extract the string after the "type="
1606 if (parts.length > 1)
1607 decode = parts[1];
1608 if (decode == null)
1609 throw new IllegalArgumentException("Invalid action string");
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -07001610
Ray Milkey269ffb92014-04-03 14:43:30 -07001611 // Remove the trailing ']'
1612 if ((decode.length() > 0) && (decode.charAt(decode.length() - 1) == ']')) {
1613 decode = decode.substring(0, decode.length() - 1);
1614 } else {
1615 throw new IllegalArgumentException("Invalid action string");
1616 }
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -07001617
Ray Milkey269ffb92014-04-03 14:43:30 -07001618 // Extract the type value and the action value
1619 parts = decode.split(" action=");
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -07001620
Ray Milkey269ffb92014-04-03 14:43:30 -07001621 // Decode the "type=XXX" payload
1622 if (parts.length > 0)
1623 decode = parts[0];
1624 if (decode != null) {
1625 try {
1626 actionType = Enum.valueOf(ActionValues.class, decode);
1627 } catch (IllegalArgumentException e) {
1628 throw new IllegalArgumentException("Invalid action string");
1629 }
1630 } else {
1631 throw new IllegalArgumentException("Invalid action string");
1632 }
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -07001633
Ray Milkey269ffb92014-04-03 14:43:30 -07001634 // Decode the "action=XXX" payload
1635 decode = null;
1636 if (parts.length > 1)
1637 decode = parts[1];
1638 if (decode == null)
1639 throw new IllegalArgumentException("Invalid action string");
1640 //
1641 try {
1642 switch (actionType) {
1643 case ACTION_OUTPUT:
1644 actionOutput = new ActionOutput(decode);
1645 break;
1646 case ACTION_SET_VLAN_VID:
1647 actionSetVlanId = new ActionSetVlanId(decode);
1648 break;
1649 case ACTION_SET_VLAN_PCP:
1650 actionSetVlanPriority = new ActionSetVlanPriority(decode);
1651 break;
1652 case ACTION_STRIP_VLAN:
1653 actionStripVlan = new ActionStripVlan(decode);
1654 break;
1655 case ACTION_SET_DL_SRC:
1656 actionSetEthernetSrcAddr = new ActionSetEthernetAddr(decode);
1657 break;
1658 case ACTION_SET_DL_DST:
1659 actionSetEthernetDstAddr = new ActionSetEthernetAddr(decode);
1660 break;
1661 case ACTION_SET_NW_SRC:
1662 actionSetIPv4SrcAddr = new ActionSetIPv4Addr(decode);
1663 break;
1664 case ACTION_SET_NW_DST:
1665 actionSetIPv4DstAddr = new ActionSetIPv4Addr(decode);
1666 break;
1667 case ACTION_SET_NW_TOS:
1668 actionSetIpToS = new ActionSetIpToS(decode);
1669 break;
1670 case ACTION_SET_TP_SRC:
1671 actionSetTcpUdpSrcPort = new ActionSetTcpUdpPort(decode);
1672 break;
1673 case ACTION_SET_TP_DST:
1674 actionSetTcpUdpDstPort = new ActionSetTcpUdpPort(decode);
1675 break;
1676 case ACTION_ENQUEUE:
1677 actionEnqueue = new ActionEnqueue(decode);
1678 break;
1679 case ACTION_VENDOR:
1680 // TODO: Handle it as appropriate
1681 break;
1682 }
1683 } catch (IllegalArgumentException e) {
1684 throw new IllegalArgumentException("Invalid action string");
1685 }
Pavlin Radoslavov1bc2c472013-07-17 18:11:37 -07001686 }
Pavlin Radoslavovede97582013-03-08 18:57:28 -08001687}