Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 1 | package net.floodlightcontroller.util; |
| 2 | |
| 3 | import net.floodlightcontroller.util.IPv4; |
| 4 | import net.floodlightcontroller.util.MACAddress; |
| 5 | import net.floodlightcontroller.util.Port; |
| 6 | |
| 7 | import org.codehaus.jackson.annotate.JsonProperty; |
| 8 | |
| 9 | /** |
| 10 | * The class representing a single Flow Entry action. |
| 11 | * |
| 12 | * A set of Flow Entry actions need to be applied to each packet. |
| 13 | */ |
| 14 | public class FlowEntryAction { |
| 15 | /** |
| 16 | * Special action values. |
| 17 | * |
| 18 | * Those values are taken as-is from the OpenFlow-v1.0.0 specification |
| 19 | * (pp 21-22). |
| 20 | */ |
| 21 | public enum ActionValues { |
| 22 | 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 |
| 35 | |
| 36 | private final short value; // The value |
| 37 | |
| 38 | /** |
| 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 | } |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Action structure for ACTION_OUTPUT: Output to switch port. |
| 50 | */ |
| 51 | public class ActionOutput { |
| 52 | private Port port; // Output port |
| 53 | private short maxLen; // Max. length (in bytes) to send to controller |
| 54 | // if the port is set to PORT_CONTROLLER |
| 55 | |
| 56 | /** |
| 57 | * Constructor for a given output port and maximum length. |
| 58 | * |
| 59 | * @param port the output port to set. |
| 60 | * @param maxLen the maximum length (in bytes) to send to controller |
| 61 | * if the port is set to PORT_CONTROLLER. |
| 62 | */ |
| 63 | public ActionOutput(Port port, short maxLen) { |
| 64 | this.port = port; |
| 65 | this.maxLen = maxLen; |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * Get the output port. |
| 70 | * |
| 71 | * @return the output port. |
| 72 | */ |
| 73 | @JsonProperty("port") |
| 74 | public Port port() { |
| 75 | return this.port; |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * Get the maximum length (in bytes) to send to controller if the |
| 80 | * port is set to PORT_CONTROLLER. |
| 81 | * |
| 82 | * @return the maximum length (in bytes) to send to controller if the |
| 83 | * port is set to PORT_CONTROLLER. |
| 84 | */ |
| 85 | @JsonProperty("maxLen") |
| 86 | public short maxLen() { |
| 87 | return this.maxLen; |
| 88 | } |
| 89 | |
| 90 | /** |
| 91 | * Convert the action to a string. |
| 92 | * |
| 93 | * The string has the following form: |
| 94 | * [port=XXX maxLen=XXX] |
| 95 | * |
| 96 | * @return the action as a string. |
| 97 | */ |
| 98 | @Override |
| 99 | public String toString() { |
| 100 | String ret = "["; |
| 101 | ret += "port=" + port.toString(); |
| 102 | ret += " maxLen=" + maxLen; |
| 103 | ret += "]"; |
| 104 | |
| 105 | return ret; |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | /** |
| 110 | * Action structure for ACTION_SET_VLAN_VID: Set the 802.1q VLAN id |
| 111 | */ |
| 112 | public class ActionSetVlanId { |
| 113 | private short vlanId; // The VLAN ID to set |
| 114 | |
| 115 | /** |
| 116 | * Constructor for a given VLAN ID. |
| 117 | * |
| 118 | * @param vlanId the VLAN ID to set. |
| 119 | */ |
| 120 | ActionSetVlanId(short vlanId) { |
| 121 | this.vlanId = vlanId; |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * Get the VLAN ID. |
| 126 | * |
| 127 | * @return the VLAN ID. |
| 128 | */ |
| 129 | @JsonProperty("vlanId") |
| 130 | public short vlanId() { |
| 131 | return this.vlanId; |
| 132 | } |
| 133 | |
| 134 | /** |
| 135 | * Convert the action to a string. |
| 136 | * |
| 137 | * The string has the following form: |
| 138 | * [vlanId=XXX] |
| 139 | * |
| 140 | * @return the action as a string. |
| 141 | */ |
| 142 | @Override |
| 143 | public String toString() { |
| 144 | String ret = "["; |
| 145 | ret += "vlanId=" + this.vlanId; |
| 146 | ret += "]"; |
| 147 | |
| 148 | return ret; |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | /** |
| 153 | * Action structure for ACTION_SET_VLAN_PCP: Set the 802.1q priority |
| 154 | */ |
| 155 | public class ActionSetVlanPriority { |
| 156 | private byte vlanPriority; // The VLAN priority to set |
| 157 | |
| 158 | /** |
| 159 | * Constructor for a given VLAN priority. |
| 160 | * |
| 161 | * @param vlanPriority the VLAN priority to set. |
| 162 | */ |
| 163 | ActionSetVlanPriority(byte vlanPriority) { |
| 164 | this.vlanPriority = vlanPriority; |
| 165 | } |
| 166 | |
| 167 | /** |
| 168 | * Get the VLAN priority. |
| 169 | * |
| 170 | * @return the VLAN priority. |
| 171 | */ |
| 172 | @JsonProperty("vlanPriority") |
| 173 | public byte vlanPriority() { |
| 174 | return this.vlanPriority; |
| 175 | } |
| 176 | |
| 177 | /** |
| 178 | * Convert the action to a string. |
| 179 | * |
| 180 | * The string has the following form: |
| 181 | * [vlanPriority=XXX] |
| 182 | * |
| 183 | * @return the action as a string. |
| 184 | */ |
| 185 | @Override |
| 186 | public String toString() { |
| 187 | String ret = "["; |
| 188 | ret += "vlanPriority=" + this.vlanPriority; |
| 189 | ret += "]"; |
| 190 | |
| 191 | return ret; |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | /** |
| 196 | * Action structure for ACTION_STRIP_VLAN: Strip the 802.1q header |
| 197 | */ |
| 198 | public class ActionStripVlan { |
| 199 | private boolean stripVlan; // If true, strip the VLAN header |
| 200 | |
| 201 | /** |
| 202 | * Constructor for a given boolean flag. |
| 203 | * |
| 204 | * @param stripVlan if true, strip the VLAN header. |
| 205 | */ |
| 206 | ActionStripVlan(boolean stripVlan) { |
| 207 | this.stripVlan = stripVlan; |
| 208 | } |
| 209 | |
| 210 | /** |
| 211 | * Get the boolean flag whether the VLAN header should be stripped. |
| 212 | * |
| 213 | * @return the boolean flag whether the VLAN header should be stripped. |
| 214 | */ |
| 215 | @JsonProperty("stripVlan") |
| 216 | public boolean stripVlan() { |
| 217 | return this.stripVlan; |
| 218 | } |
| 219 | |
| 220 | /** |
| 221 | * Convert the action to a string. |
| 222 | * |
| 223 | * The string has the following form: |
| 224 | * [stripVlan=XXX] |
| 225 | * |
| 226 | * @return the action as a string. |
| 227 | */ |
| 228 | @Override |
| 229 | public String toString() { |
| 230 | String ret = "["; |
| 231 | ret += "stripVlan=" + this.stripVlan; |
| 232 | ret += "]"; |
| 233 | |
| 234 | return ret; |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | /** |
| 239 | * Action structure for ACTION_SET_DL_SRC and ACTION_SET_DL_DST: |
| 240 | * Set the Ethernet source/destination address. |
| 241 | */ |
| 242 | public class ActionSetEthernetAddr { |
| 243 | private MACAddress addr; // The MAC address to set |
| 244 | |
| 245 | /** |
| 246 | * Constructor for a given MAC address. |
| 247 | * |
| 248 | * @param addr the MAC address to set. |
| 249 | */ |
| 250 | ActionSetEthernetAddr(MACAddress addr) { |
| 251 | this.addr = addr; |
| 252 | } |
| 253 | |
| 254 | /** |
| 255 | * Get the MAC address. |
| 256 | * |
| 257 | * @return the MAC address. |
| 258 | */ |
| 259 | @JsonProperty("addr") |
| 260 | public MACAddress addr() { |
| 261 | return this.addr; |
| 262 | } |
| 263 | |
| 264 | /** |
| 265 | * Convert the action to a string. |
| 266 | * |
| 267 | * The string has the following form: |
| 268 | * [addr=XXX] |
| 269 | * |
| 270 | * @return the action as a string. |
| 271 | */ |
| 272 | @Override |
| 273 | public String toString() { |
| 274 | String ret = "["; |
| 275 | ret += "addr=" + addr.toString(); |
| 276 | ret += "]"; |
| 277 | |
| 278 | return ret; |
| 279 | } |
| 280 | } |
| 281 | |
| 282 | /** |
| 283 | * Action structure for ACTION_SET_NW_SRC and ACTION_SET_NW_DST: |
| 284 | * Set the IPv4 source/destination address. |
| 285 | */ |
| 286 | public class ActionSetIPv4Addr { |
| 287 | private IPv4 addr; // The IPv4 address to set |
| 288 | |
| 289 | /** |
| 290 | * Constructor for a given IPv4 address. |
| 291 | * |
| 292 | * @param addr the IPv4 address to set. |
| 293 | */ |
| 294 | ActionSetIPv4Addr(IPv4 addr) { |
| 295 | this.addr = addr; |
| 296 | } |
| 297 | |
| 298 | /** |
| 299 | * Get the IPv4 address. |
| 300 | * |
| 301 | * @return the IPv4 address. |
| 302 | */ |
| 303 | @JsonProperty("addr") |
| 304 | public IPv4 addr() { |
| 305 | return this.addr; |
| 306 | } |
| 307 | |
| 308 | /** |
| 309 | * Convert the action to a string. |
| 310 | * |
| 311 | * The string has the following form: |
| 312 | * [addr=XXX] |
| 313 | * |
| 314 | * @return the action as a string. |
| 315 | */ |
| 316 | @Override |
| 317 | public String toString() { |
| 318 | String ret = "["; |
| 319 | ret += "addr=" + addr.toString(); |
| 320 | ret += "]"; |
| 321 | |
| 322 | return ret; |
| 323 | } |
| 324 | } |
| 325 | |
| 326 | /** |
| 327 | * Action structure for ACTION_SET_NW_TOS: |
| 328 | * Set the IP ToS (DSCP field, 6 bits). |
| 329 | */ |
| 330 | public class ActionSetIpToS { |
| 331 | private byte ipToS; // The IP ToS to set DSCP field, 6 bits) |
| 332 | |
| 333 | /** |
| 334 | * Constructor for a given IP ToS (DSCP field, 6 bits). |
| 335 | * |
| 336 | * @param ipToS the IP ToS (DSCP field, 6 bits) to set. |
| 337 | */ |
| 338 | ActionSetIpToS(byte ipToS) { |
| 339 | this.ipToS = ipToS; |
| 340 | } |
| 341 | |
| 342 | /** |
| 343 | * Get the IP ToS (DSCP field, 6 bits). |
| 344 | * |
| 345 | * @return the IP ToS (DSCP field, 6 bits). |
| 346 | */ |
| 347 | @JsonProperty("ipToS") |
| 348 | public byte ipToS() { |
| 349 | return this.ipToS; |
| 350 | } |
| 351 | |
| 352 | /** |
| 353 | * Convert the action to a string. |
| 354 | * |
| 355 | * The string has the following form: |
| 356 | * [ipToS=XXX] |
| 357 | * |
| 358 | * @return the action as a string. |
| 359 | */ |
| 360 | @Override |
| 361 | public String toString() { |
| 362 | String ret = "["; |
| 363 | ret += "ipToS=" + ipToS; |
| 364 | ret += "]"; |
| 365 | |
| 366 | return ret; |
| 367 | } |
| 368 | } |
| 369 | |
| 370 | /** |
| 371 | * Action structure for ACTION_SET_TP_SRC and ACTION_SET_TP_DST: |
| 372 | * Set the TCP/UDP source/destination port. |
| 373 | */ |
| 374 | public class ActionSetTcpUdpPort { |
| 375 | private short port; // The TCP/UDP port to set |
| 376 | |
| 377 | /** |
| 378 | * Constructor for a given TCP/UDP port. |
| 379 | * |
| 380 | * @param port the TCP/UDP port to set. |
| 381 | */ |
| 382 | ActionSetTcpUdpPort(short port) { |
| 383 | this.port = port; |
| 384 | } |
| 385 | |
| 386 | /** |
| 387 | * Get the TCP/UDP port. |
| 388 | * |
| 389 | * @return the TCP/UDP port. |
| 390 | */ |
| 391 | @JsonProperty("port") |
| 392 | public short port() { |
| 393 | return this.port; |
| 394 | } |
| 395 | |
| 396 | /** |
| 397 | * Convert the action to a string. |
| 398 | * |
| 399 | * The string has the following form: |
| 400 | * [port=XXX] |
| 401 | * |
| 402 | * @return the action as a string. |
| 403 | */ |
| 404 | @Override |
| 405 | public String toString() { |
| 406 | String ret = "["; |
| 407 | ret += "port=" + port; |
| 408 | ret += "]"; |
| 409 | |
| 410 | return ret; |
| 411 | } |
| 412 | } |
| 413 | |
| 414 | /** |
| 415 | * Action structure for ACTION_ENQUEUE: Output to queue on port. |
| 416 | */ |
| 417 | public class ActionEnqueue { |
| 418 | private Port port; // Port that queue belongs. Should |
| 419 | // refer to a valid physical port |
| 420 | // (i.e. < PORT_MAX) or PORT_IN_PORT |
| 421 | private int queueId; // Where to enqueue the packets |
| 422 | |
| 423 | /** |
| 424 | * Constructor for a given port and queue ID. |
| 425 | * |
| 426 | * @param port the port to set. |
| 427 | * @param queueId the queue ID on the port. |
| 428 | */ |
| 429 | public ActionEnqueue(Port port, int queueId) { |
| 430 | this.port = port; |
| 431 | this.queueId = queueId; |
| 432 | } |
| 433 | |
| 434 | /** |
| 435 | * Get the port. |
| 436 | * |
| 437 | * @return the port. |
| 438 | */ |
| 439 | @JsonProperty("port") |
| 440 | public Port port() { |
| 441 | return this.port; |
| 442 | } |
| 443 | |
| 444 | /** |
| 445 | * Get the queue ID. |
| 446 | * |
| 447 | * @return the queue ID. |
| 448 | */ |
| 449 | @JsonProperty("queueId") |
| 450 | public int queueId() { |
| 451 | return this.queueId; |
| 452 | } |
| 453 | |
| 454 | /** |
| 455 | * Convert the action to a string. |
| 456 | * |
| 457 | * The string has the following form: |
| 458 | * [port=XXX queueId=XXX] |
| 459 | * |
| 460 | * @return the action as a string. |
| 461 | */ |
| 462 | @Override |
| 463 | public String toString() { |
| 464 | String ret = "["; |
| 465 | ret += "port=" + port.toString(); |
| 466 | ret += " queueId=" + queueId; |
| 467 | ret += "]"; |
| 468 | |
| 469 | return ret; |
| 470 | } |
| 471 | } |
| 472 | |
| 473 | private ActionValues actionType; // The action type |
| 474 | |
| 475 | // |
| 476 | // The actions. |
| 477 | // NOTE: Only one action should be set. |
| 478 | // |
| 479 | private ActionOutput actionOutput; |
| 480 | private ActionSetVlanId actionSetVlanId; |
| 481 | private ActionSetVlanPriority actionSetVlanPriority; |
| 482 | private ActionStripVlan actionStripVlan; |
| 483 | private ActionSetEthernetAddr actionSetEthernetSrcAddr; |
| 484 | private ActionSetEthernetAddr actionSetEthernetDstAddr; |
| 485 | private ActionSetIPv4Addr actionSetIPv4SrcAddr; |
| 486 | private ActionSetIPv4Addr actionSetIPv4DstAddr; |
| 487 | private ActionSetIpToS actionSetIpToS; |
| 488 | private ActionSetTcpUdpPort actionSetTcpUdpSrcPort; |
| 489 | private ActionSetTcpUdpPort actionSetTcpUdpDstPort; |
| 490 | private ActionEnqueue actionEnqueue; |
| 491 | |
| 492 | /** |
| 493 | * Default constructor. |
| 494 | */ |
| 495 | public FlowEntryAction() { |
| 496 | actionType = ActionValues.ACTION_VENDOR; // XXX: Initial value |
| 497 | } |
| 498 | |
| 499 | /** |
| 500 | * Get the action type. |
| 501 | * |
| 502 | * @return the action type. |
| 503 | */ |
| 504 | @JsonProperty("actionType") |
| 505 | public ActionValues actionType() { return actionType; } |
| 506 | |
| 507 | /** |
| 508 | * Get the output action. |
| 509 | * |
| 510 | * @return the output action. |
| 511 | */ |
| 512 | @JsonProperty("actionOutput") |
| 513 | public ActionOutput actionOutput() { return actionOutput; } |
| 514 | |
| 515 | /** |
| 516 | * Set the output action on a port. |
| 517 | * |
| 518 | * @param port the output port to set. |
| 519 | */ |
| 520 | @JsonProperty("actionOutput") |
| 521 | public void setActionOutput(Port port) { |
| 522 | actionOutput = new ActionOutput(port, (short)0); |
| 523 | actionType = ActionValues.ACTION_OUTPUT; |
| 524 | } |
| 525 | |
| 526 | /** |
| 527 | * Set the output action to controller. |
| 528 | * |
| 529 | * @param maxLen the maximum length (in bytes) to send to controller. |
| 530 | */ |
| 531 | @JsonProperty("actionOutputToController") |
| 532 | public void setActionOutputToController(short maxLen) { |
| 533 | Port port = new Port(Port.PortValues.PORT_CONTROLLER); |
| 534 | actionOutput = new ActionOutput(port, maxLen); |
| 535 | actionType = ActionValues.ACTION_OUTPUT; |
| 536 | } |
| 537 | |
| 538 | /** |
| 539 | * Get the action to set the VLAN ID. |
| 540 | * |
| 541 | * @return the action to set the VLAN ID. |
| 542 | */ |
| 543 | @JsonProperty("actionSetVlanId") |
| 544 | public ActionSetVlanId actionSetVlanId() { return actionSetVlanId; } |
| 545 | |
| 546 | /** |
| 547 | * Set the action to set the VLAN ID. |
| 548 | * |
| 549 | * @param vlanId the VLAN ID to set. |
| 550 | */ |
| 551 | @JsonProperty("actionSetVlanId") |
| 552 | public void setActionSetVlanId(short vlanId) { |
| 553 | actionSetVlanId = new ActionSetVlanId(vlanId); |
| 554 | actionType = ActionValues.ACTION_SET_VLAN_VID; |
| 555 | } |
| 556 | |
| 557 | /** |
| 558 | * Get the action to set the VLAN priority. |
| 559 | * |
| 560 | * @return the action to set the VLAN priority. |
| 561 | */ |
| 562 | @JsonProperty("actionSetVlanPriority") |
| 563 | public ActionSetVlanPriority actionSetVlanPriority() { |
| 564 | return actionSetVlanPriority; |
| 565 | } |
| 566 | |
| 567 | /** |
| 568 | * Set the action to set the VLAN priority. |
| 569 | * |
| 570 | * @param vlanPriority the VLAN priority to set. |
| 571 | */ |
| 572 | @JsonProperty("actionSetVlanPriority") |
| 573 | public void setActionSetVlanPriority(byte vlanPriority) { |
| 574 | actionSetVlanPriority = new ActionSetVlanPriority(vlanPriority); |
| 575 | actionType = ActionValues.ACTION_SET_VLAN_PCP; |
| 576 | } |
| 577 | |
| 578 | /** |
| 579 | * Get the action to strip the VLAN header. |
| 580 | * |
| 581 | * @return the action to strip the VLAN header. |
| 582 | */ |
| 583 | @JsonProperty("actionStripVlan") |
| 584 | public ActionStripVlan actionStripVlan() { |
| 585 | return actionStripVlan; |
| 586 | } |
| 587 | |
| 588 | /** |
| 589 | * Set the action to strip the VLAN header. |
| 590 | * |
| 591 | * @param stripVlan if true, strip the VLAN header. |
| 592 | */ |
| 593 | @JsonProperty("actionStripVlan") |
| 594 | public void setActionStripVlan(boolean stripVlan) { |
| 595 | actionStripVlan = new ActionStripVlan(stripVlan); |
| 596 | actionType = ActionValues.ACTION_STRIP_VLAN; |
| 597 | } |
| 598 | |
| 599 | /** |
| 600 | * Get the action to set the Ethernet source address. |
| 601 | * |
| 602 | * @return the action to set the Ethernet source address. |
| 603 | */ |
| 604 | @JsonProperty("actionSetEthernetSrcAddr") |
| 605 | public ActionSetEthernetAddr actionSetEthernetSrcAddr() { |
| 606 | return actionSetEthernetSrcAddr; |
| 607 | } |
| 608 | |
| 609 | /** |
| 610 | * Set the action to set the Ethernet source address. |
| 611 | * |
| 612 | * @param addr the MAC address to set as the Ethernet source address. |
| 613 | */ |
| 614 | @JsonProperty("actionSetEthernetSrcAddr") |
| 615 | public void setActionSetEthernetSrcAddr(MACAddress addr) { |
| 616 | actionSetEthernetSrcAddr = new ActionSetEthernetAddr(addr); |
| 617 | actionType = ActionValues.ACTION_SET_DL_SRC; |
| 618 | } |
| 619 | |
| 620 | /** |
| 621 | * Get the action to set the Ethernet destination address. |
| 622 | * |
| 623 | * @return the action to set the Ethernet destination address. |
| 624 | */ |
| 625 | @JsonProperty("actionSetEthernetDstAddr") |
| 626 | public ActionSetEthernetAddr actionSetEthernetDstAddr() { |
| 627 | return actionSetEthernetDstAddr; |
| 628 | } |
| 629 | |
| 630 | /** |
| 631 | * Set the action to set the Ethernet destination address. |
| 632 | * |
| 633 | * @param addr the MAC address to set as the Ethernet destination address. |
| 634 | */ |
| 635 | @JsonProperty("actionSetEthernetDstAddr") |
| 636 | public void setActionSetEthernetDstAddr(MACAddress addr) { |
| 637 | actionSetEthernetDstAddr = new ActionSetEthernetAddr(addr); |
| 638 | actionType = ActionValues.ACTION_SET_DL_DST; |
| 639 | } |
| 640 | |
| 641 | /** |
| 642 | * Get the action to set the IPv4 source address. |
| 643 | * |
| 644 | * @return the action to set the IPv4 source address. |
| 645 | */ |
| 646 | @JsonProperty("actionSetIPv4SrcAddr") |
| 647 | public ActionSetIPv4Addr actionSetIPv4SrcAddr() { |
| 648 | return actionSetIPv4SrcAddr; |
| 649 | } |
| 650 | |
| 651 | /** |
| 652 | * Set the action to set the IPv4 source address. |
| 653 | * |
| 654 | * @param addr the IPv4 address to set as the IPv4 source address. |
| 655 | */ |
| 656 | @JsonProperty("actionSetIPv4SrcAddr") |
| 657 | public void setActionSetIPv4SrcAddr(IPv4 addr) { |
| 658 | actionSetIPv4SrcAddr = new ActionSetIPv4Addr(addr); |
| 659 | actionType = ActionValues.ACTION_SET_NW_SRC; |
| 660 | } |
| 661 | |
| 662 | /** |
| 663 | * Get the action to set the IPv4 destination address. |
| 664 | * |
| 665 | * @return the action to set the IPv4 destination address. |
| 666 | */ |
| 667 | @JsonProperty("actionSetIPv4DstAddr") |
| 668 | public ActionSetIPv4Addr actionSetIPv4DstAddr() { |
| 669 | return actionSetIPv4DstAddr; |
| 670 | } |
| 671 | |
| 672 | /** |
| 673 | * Set the action to set the IPv4 destination address. |
| 674 | * |
| 675 | * @param addr the IPv4 address to set as the IPv4 destination address. |
| 676 | */ |
| 677 | @JsonProperty("actionSetIPv4DstAddr") |
| 678 | public void setActionSetIPv4DstAddr(IPv4 addr) { |
| 679 | actionSetIPv4DstAddr = new ActionSetIPv4Addr(addr); |
| 680 | actionType = ActionValues.ACTION_SET_NW_DST; |
| 681 | } |
| 682 | |
| 683 | /** |
| 684 | * Get the action to set the IP ToS (DSCP field, 6 bits). |
| 685 | * |
| 686 | * @return the action to set the IP ToS (DSCP field, 6 bits). |
| 687 | */ |
| 688 | @JsonProperty("actionSetIpToS") |
| 689 | public ActionSetIpToS actionSetIpToS() { |
| 690 | return actionSetIpToS; |
| 691 | } |
| 692 | |
| 693 | /** |
| 694 | * Set the action to set the IP ToS (DSCP field, 6 bits). |
| 695 | * |
| 696 | * @param ipToS the IP ToS (DSCP field, 6 bits) to set. |
| 697 | */ |
| 698 | @JsonProperty("actionSetIpToS") |
| 699 | public void setActionSetIpToS(byte ipToS) { |
| 700 | actionSetIpToS = new ActionSetIpToS(ipToS); |
| 701 | actionType = ActionValues.ACTION_SET_NW_TOS; |
| 702 | } |
| 703 | |
| 704 | /** |
| 705 | * Get the action to set the TCP/UDP source port. |
| 706 | * |
| 707 | * @return the action to set the TCP/UDP source port. |
| 708 | */ |
| 709 | @JsonProperty("actionSetTcpUdpSrcPort") |
| 710 | public ActionSetTcpUdpPort actionSetTcpUdpSrcPort() { |
| 711 | return actionSetTcpUdpSrcPort; |
| 712 | } |
| 713 | |
| 714 | /** |
| 715 | * Set the action to set the TCP/UDP source port. |
| 716 | * |
| 717 | * @param port the TCP/UDP port to set as the TCP/UDP source port. |
| 718 | */ |
| 719 | @JsonProperty("actionSetTcpUdpSrcPort") |
| 720 | public void setActionSetTcpUdpSrcPort(short port) { |
| 721 | actionSetTcpUdpSrcPort = new ActionSetTcpUdpPort(port); |
| 722 | actionType = ActionValues.ACTION_SET_TP_SRC; |
| 723 | } |
| 724 | |
| 725 | /** |
| 726 | * Get the action to set the TCP/UDP destination port. |
| 727 | * |
| 728 | * @return the action to set the TCP/UDP destination port. |
| 729 | */ |
| 730 | @JsonProperty("actionSetTcpUdpDstPort") |
| 731 | public ActionSetTcpUdpPort actionSetTcpUdpDstPort() { |
| 732 | return actionSetTcpUdpDstPort; |
| 733 | } |
| 734 | |
| 735 | /** |
| 736 | * Set the action to set the TCP/UDP destination port. |
| 737 | * |
| 738 | * @param port the TCP/UDP port to set as the TCP/UDP destination port. |
| 739 | */ |
| 740 | @JsonProperty("actionSetTcpUdpDstPort") |
| 741 | public void setActionSetTcpUdpDstPort(short port) { |
| 742 | actionSetTcpUdpDstPort = new ActionSetTcpUdpPort(port); |
| 743 | actionType = ActionValues.ACTION_SET_TP_DST; |
| 744 | } |
| 745 | |
| 746 | /** |
| 747 | * Get the action to output to queue on a port. |
| 748 | * |
| 749 | * @return the action to output to queue on a port. |
| 750 | */ |
| 751 | @JsonProperty("actionEnqueue") |
| 752 | public ActionEnqueue actionEnqueue() { return actionEnqueue; } |
| 753 | |
| 754 | /** |
| 755 | * Set the action to output to queue on a port. |
| 756 | * |
| 757 | * @param port the port to set. |
| 758 | * @param int queueId the queue ID to set. |
| 759 | */ |
| 760 | @JsonProperty("actionEnqueue") |
| 761 | public void setActionEnqueue(Port port, int queueId) { |
| 762 | actionEnqueue = new ActionEnqueue(port, queueId); |
| 763 | actionType = ActionValues.ACTION_ENQUEUE; |
| 764 | } |
| 765 | |
| 766 | /** |
| 767 | * Convert the set of actions to a string. |
| 768 | * |
| 769 | * The string has the following form: |
| 770 | * [type=XXX action=XXX] |
| 771 | * |
| 772 | * @return the set of actions as a string. |
| 773 | */ |
| 774 | @Override |
| 775 | public String toString() { |
| 776 | String ret = "["; |
| 777 | ret += "type=" + actionType; |
| 778 | switch (actionType) { |
| 779 | case ACTION_OUTPUT: |
| 780 | ret += " action=" + actionOutput.toString(); |
| 781 | break; |
| 782 | case ACTION_SET_VLAN_VID: |
| 783 | ret += " action=" + actionSetVlanId.toString(); |
| 784 | break; |
| 785 | case ACTION_SET_VLAN_PCP: |
| 786 | ret += " action=" + actionSetVlanPriority.toString(); |
| 787 | break; |
| 788 | case ACTION_STRIP_VLAN: |
| 789 | ret += " action=" + actionStripVlan.toString(); |
| 790 | break; |
| 791 | case ACTION_SET_DL_SRC: |
| 792 | ret += " action=" + actionSetEthernetSrcAddr.toString(); |
| 793 | break; |
| 794 | case ACTION_SET_DL_DST: |
| 795 | ret += " action=" + actionSetEthernetDstAddr.toString(); |
| 796 | break; |
| 797 | case ACTION_SET_NW_SRC: |
| 798 | ret += " action=" + actionSetIPv4SrcAddr.toString(); |
| 799 | break; |
| 800 | case ACTION_SET_NW_DST: |
| 801 | ret += " action=" + actionSetIPv4DstAddr.toString(); |
| 802 | break; |
| 803 | case ACTION_SET_NW_TOS: |
| 804 | ret += " action=" + actionSetIpToS.toString(); |
| 805 | break; |
| 806 | case ACTION_SET_TP_SRC: |
| 807 | ret += " action=" + actionSetTcpUdpSrcPort.toString(); |
| 808 | break; |
| 809 | case ACTION_SET_TP_DST: |
| 810 | ret += " action=" + actionSetTcpUdpDstPort.toString(); |
| 811 | break; |
| 812 | case ACTION_ENQUEUE: |
| 813 | ret += " action=" + actionEnqueue.toString(); |
| 814 | break; |
| 815 | } |
| 816 | ret += "]"; |
| 817 | |
| 818 | return ret; |
| 819 | } |
| 820 | } |