alshabib | 86ac11c | 2014-08-14 16:14:41 -0700 | [diff] [blame] | 1 | // Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University |
| 2 | // Copyright (c) 2011, 2012 Open Networking Foundation |
| 3 | // Copyright (c) 2012, 2013 Big Switch Networks, Inc. |
| 4 | // This library was generated by the LoxiGen Compiler. |
| 5 | // See the file LICENSE.txt which should have been included in the source distribution |
| 6 | |
| 7 | // Automatically generated by LOXI from template of_class.java |
| 8 | // Do not modify |
| 9 | |
| 10 | package org.projectfloodlight.openflow.protocol.ver12; |
| 11 | |
| 12 | import org.projectfloodlight.openflow.protocol.*; |
| 13 | import org.projectfloodlight.openflow.protocol.action.*; |
| 14 | import org.projectfloodlight.openflow.protocol.actionid.*; |
| 15 | import org.projectfloodlight.openflow.protocol.bsntlv.*; |
| 16 | import org.projectfloodlight.openflow.protocol.errormsg.*; |
| 17 | import org.projectfloodlight.openflow.protocol.meterband.*; |
| 18 | import org.projectfloodlight.openflow.protocol.instruction.*; |
| 19 | import org.projectfloodlight.openflow.protocol.instructionid.*; |
| 20 | import org.projectfloodlight.openflow.protocol.match.*; |
| 21 | import org.projectfloodlight.openflow.protocol.oxm.*; |
| 22 | import org.projectfloodlight.openflow.protocol.queueprop.*; |
| 23 | import org.projectfloodlight.openflow.types.*; |
| 24 | import org.projectfloodlight.openflow.util.*; |
| 25 | import org.projectfloodlight.openflow.exceptions.*; |
| 26 | import org.slf4j.Logger; |
| 27 | import org.slf4j.LoggerFactory; |
| 28 | import java.util.Set; |
| 29 | import com.google.common.collect.ImmutableSet; |
| 30 | import java.util.List; |
| 31 | import com.google.common.collect.ImmutableList; |
| 32 | import org.jboss.netty.buffer.ChannelBuffer; |
| 33 | import com.google.common.hash.PrimitiveSink; |
| 34 | import com.google.common.hash.Funnel; |
| 35 | |
| 36 | class OFFlowDeleteVer12 implements OFFlowDelete { |
| 37 | private static final Logger logger = LoggerFactory.getLogger(OFFlowDeleteVer12.class); |
| 38 | // version: 1.2 |
| 39 | final static byte WIRE_VERSION = 3; |
| 40 | final static int MINIMUM_LENGTH = 56; |
| 41 | |
| 42 | private final static long DEFAULT_XID = 0x0L; |
| 43 | private final static U64 DEFAULT_COOKIE = U64.ZERO; |
| 44 | private final static U64 DEFAULT_COOKIE_MASK = U64.ZERO; |
| 45 | private final static TableId DEFAULT_TABLE_ID = TableId.ZERO; |
| 46 | private final static int DEFAULT_IDLE_TIMEOUT = 0x0; |
| 47 | private final static int DEFAULT_HARD_TIMEOUT = 0x0; |
| 48 | private final static int DEFAULT_PRIORITY = 0x0; |
| 49 | private final static OFBufferId DEFAULT_BUFFER_ID = OFBufferId.NO_BUFFER; |
| 50 | private final static OFPort DEFAULT_OUT_PORT = OFPort.ANY; |
| 51 | private final static OFGroup DEFAULT_OUT_GROUP = OFGroup.ANY; |
| 52 | private final static Set<OFFlowModFlags> DEFAULT_FLAGS = ImmutableSet.<OFFlowModFlags>of(); |
| 53 | private final static Match DEFAULT_MATCH = OFFactoryVer12.MATCH_WILDCARD_ALL; |
| 54 | private final static List<OFInstruction> DEFAULT_INSTRUCTIONS = ImmutableList.<OFInstruction>of(); |
| 55 | |
| 56 | // OF message fields |
| 57 | private final long xid; |
| 58 | private final U64 cookie; |
| 59 | private final U64 cookieMask; |
| 60 | private final TableId tableId; |
| 61 | private final int idleTimeout; |
| 62 | private final int hardTimeout; |
| 63 | private final int priority; |
| 64 | private final OFBufferId bufferId; |
| 65 | private final OFPort outPort; |
| 66 | private final OFGroup outGroup; |
| 67 | private final Set<OFFlowModFlags> flags; |
| 68 | private final Match match; |
| 69 | private final List<OFInstruction> instructions; |
| 70 | // |
| 71 | // Immutable default instance |
| 72 | final static OFFlowDeleteVer12 DEFAULT = new OFFlowDeleteVer12( |
| 73 | DEFAULT_XID, DEFAULT_COOKIE, DEFAULT_COOKIE_MASK, DEFAULT_TABLE_ID, DEFAULT_IDLE_TIMEOUT, DEFAULT_HARD_TIMEOUT, DEFAULT_PRIORITY, DEFAULT_BUFFER_ID, DEFAULT_OUT_PORT, DEFAULT_OUT_GROUP, DEFAULT_FLAGS, DEFAULT_MATCH, DEFAULT_INSTRUCTIONS |
| 74 | ); |
| 75 | |
| 76 | // package private constructor - used by readers, builders, and factory |
| 77 | OFFlowDeleteVer12(long xid, U64 cookie, U64 cookieMask, TableId tableId, int idleTimeout, int hardTimeout, int priority, OFBufferId bufferId, OFPort outPort, OFGroup outGroup, Set<OFFlowModFlags> flags, Match match, List<OFInstruction> instructions) { |
| 78 | this.xid = xid; |
| 79 | this.cookie = cookie; |
| 80 | this.cookieMask = cookieMask; |
| 81 | this.tableId = tableId; |
| 82 | this.idleTimeout = idleTimeout; |
| 83 | this.hardTimeout = hardTimeout; |
| 84 | this.priority = priority; |
| 85 | this.bufferId = bufferId; |
| 86 | this.outPort = outPort; |
| 87 | this.outGroup = outGroup; |
| 88 | this.flags = flags; |
| 89 | this.match = match; |
| 90 | this.instructions = instructions; |
| 91 | } |
| 92 | |
| 93 | // Accessors for OF message fields |
| 94 | @Override |
| 95 | public OFVersion getVersion() { |
| 96 | return OFVersion.OF_12; |
| 97 | } |
| 98 | |
| 99 | @Override |
| 100 | public OFType getType() { |
| 101 | return OFType.FLOW_MOD; |
| 102 | } |
| 103 | |
| 104 | @Override |
| 105 | public long getXid() { |
| 106 | return xid; |
| 107 | } |
| 108 | |
| 109 | @Override |
| 110 | public U64 getCookie() { |
| 111 | return cookie; |
| 112 | } |
| 113 | |
| 114 | @Override |
| 115 | public U64 getCookieMask() { |
| 116 | return cookieMask; |
| 117 | } |
| 118 | |
| 119 | @Override |
| 120 | public TableId getTableId() { |
| 121 | return tableId; |
| 122 | } |
| 123 | |
| 124 | @Override |
| 125 | public OFFlowModCommand getCommand() { |
| 126 | return OFFlowModCommand.DELETE; |
| 127 | } |
| 128 | |
| 129 | @Override |
| 130 | public int getIdleTimeout() { |
| 131 | return idleTimeout; |
| 132 | } |
| 133 | |
| 134 | @Override |
| 135 | public int getHardTimeout() { |
| 136 | return hardTimeout; |
| 137 | } |
| 138 | |
| 139 | @Override |
| 140 | public int getPriority() { |
| 141 | return priority; |
| 142 | } |
| 143 | |
| 144 | @Override |
| 145 | public OFBufferId getBufferId() { |
| 146 | return bufferId; |
| 147 | } |
| 148 | |
| 149 | @Override |
| 150 | public OFPort getOutPort() { |
| 151 | return outPort; |
| 152 | } |
| 153 | |
| 154 | @Override |
| 155 | public OFGroup getOutGroup() { |
| 156 | return outGroup; |
| 157 | } |
| 158 | |
| 159 | @Override |
| 160 | public Set<OFFlowModFlags> getFlags() { |
| 161 | return flags; |
| 162 | } |
| 163 | |
| 164 | @Override |
| 165 | public Match getMatch() { |
| 166 | return match; |
| 167 | } |
| 168 | |
| 169 | @Override |
| 170 | public List<OFInstruction> getInstructions() { |
| 171 | return instructions; |
| 172 | } |
| 173 | |
| 174 | @Override |
| 175 | public List<OFAction> getActions()throws UnsupportedOperationException { |
| 176 | throw new UnsupportedOperationException("Property actions not supported in version 1.2"); |
| 177 | } |
| 178 | |
| 179 | |
| 180 | |
| 181 | public OFFlowDelete.Builder createBuilder() { |
| 182 | return new BuilderWithParent(this); |
| 183 | } |
| 184 | |
| 185 | static class BuilderWithParent implements OFFlowDelete.Builder { |
| 186 | final OFFlowDeleteVer12 parentMessage; |
| 187 | |
| 188 | // OF message fields |
| 189 | private boolean xidSet; |
| 190 | private long xid; |
| 191 | private boolean cookieSet; |
| 192 | private U64 cookie; |
| 193 | private boolean cookieMaskSet; |
| 194 | private U64 cookieMask; |
| 195 | private boolean tableIdSet; |
| 196 | private TableId tableId; |
| 197 | private boolean idleTimeoutSet; |
| 198 | private int idleTimeout; |
| 199 | private boolean hardTimeoutSet; |
| 200 | private int hardTimeout; |
| 201 | private boolean prioritySet; |
| 202 | private int priority; |
| 203 | private boolean bufferIdSet; |
| 204 | private OFBufferId bufferId; |
| 205 | private boolean outPortSet; |
| 206 | private OFPort outPort; |
| 207 | private boolean outGroupSet; |
| 208 | private OFGroup outGroup; |
| 209 | private boolean flagsSet; |
| 210 | private Set<OFFlowModFlags> flags; |
| 211 | private boolean matchSet; |
| 212 | private Match match; |
| 213 | private boolean instructionsSet; |
| 214 | private List<OFInstruction> instructions; |
| 215 | |
| 216 | BuilderWithParent(OFFlowDeleteVer12 parentMessage) { |
| 217 | this.parentMessage = parentMessage; |
| 218 | } |
| 219 | |
| 220 | @Override |
| 221 | public OFVersion getVersion() { |
| 222 | return OFVersion.OF_12; |
| 223 | } |
| 224 | |
| 225 | @Override |
| 226 | public OFType getType() { |
| 227 | return OFType.FLOW_MOD; |
| 228 | } |
| 229 | |
| 230 | @Override |
| 231 | public long getXid() { |
| 232 | return xid; |
| 233 | } |
| 234 | |
| 235 | @Override |
| 236 | public OFFlowDelete.Builder setXid(long xid) { |
| 237 | this.xid = xid; |
| 238 | this.xidSet = true; |
| 239 | return this; |
| 240 | } |
| 241 | @Override |
| 242 | public U64 getCookie() { |
| 243 | return cookie; |
| 244 | } |
| 245 | |
| 246 | @Override |
| 247 | public OFFlowDelete.Builder setCookie(U64 cookie) { |
| 248 | this.cookie = cookie; |
| 249 | this.cookieSet = true; |
| 250 | return this; |
| 251 | } |
| 252 | @Override |
| 253 | public U64 getCookieMask() { |
| 254 | return cookieMask; |
| 255 | } |
| 256 | |
| 257 | @Override |
| 258 | public OFFlowDelete.Builder setCookieMask(U64 cookieMask) { |
| 259 | this.cookieMask = cookieMask; |
| 260 | this.cookieMaskSet = true; |
| 261 | return this; |
| 262 | } |
| 263 | @Override |
| 264 | public TableId getTableId() { |
| 265 | return tableId; |
| 266 | } |
| 267 | |
| 268 | @Override |
| 269 | public OFFlowDelete.Builder setTableId(TableId tableId) { |
| 270 | this.tableId = tableId; |
| 271 | this.tableIdSet = true; |
| 272 | return this; |
| 273 | } |
| 274 | @Override |
| 275 | public OFFlowModCommand getCommand() { |
| 276 | return OFFlowModCommand.DELETE; |
| 277 | } |
| 278 | |
| 279 | @Override |
| 280 | public int getIdleTimeout() { |
| 281 | return idleTimeout; |
| 282 | } |
| 283 | |
| 284 | @Override |
| 285 | public OFFlowDelete.Builder setIdleTimeout(int idleTimeout) { |
| 286 | this.idleTimeout = idleTimeout; |
| 287 | this.idleTimeoutSet = true; |
| 288 | return this; |
| 289 | } |
| 290 | @Override |
| 291 | public int getHardTimeout() { |
| 292 | return hardTimeout; |
| 293 | } |
| 294 | |
| 295 | @Override |
| 296 | public OFFlowDelete.Builder setHardTimeout(int hardTimeout) { |
| 297 | this.hardTimeout = hardTimeout; |
| 298 | this.hardTimeoutSet = true; |
| 299 | return this; |
| 300 | } |
| 301 | @Override |
| 302 | public int getPriority() { |
| 303 | return priority; |
| 304 | } |
| 305 | |
| 306 | @Override |
| 307 | public OFFlowDelete.Builder setPriority(int priority) { |
| 308 | this.priority = priority; |
| 309 | this.prioritySet = true; |
| 310 | return this; |
| 311 | } |
| 312 | @Override |
| 313 | public OFBufferId getBufferId() { |
| 314 | return bufferId; |
| 315 | } |
| 316 | |
| 317 | @Override |
| 318 | public OFFlowDelete.Builder setBufferId(OFBufferId bufferId) { |
| 319 | this.bufferId = bufferId; |
| 320 | this.bufferIdSet = true; |
| 321 | return this; |
| 322 | } |
| 323 | @Override |
| 324 | public OFPort getOutPort() { |
| 325 | return outPort; |
| 326 | } |
| 327 | |
| 328 | @Override |
| 329 | public OFFlowDelete.Builder setOutPort(OFPort outPort) { |
| 330 | this.outPort = outPort; |
| 331 | this.outPortSet = true; |
| 332 | return this; |
| 333 | } |
| 334 | @Override |
| 335 | public OFGroup getOutGroup() { |
| 336 | return outGroup; |
| 337 | } |
| 338 | |
| 339 | @Override |
| 340 | public OFFlowDelete.Builder setOutGroup(OFGroup outGroup) { |
| 341 | this.outGroup = outGroup; |
| 342 | this.outGroupSet = true; |
| 343 | return this; |
| 344 | } |
| 345 | @Override |
| 346 | public Set<OFFlowModFlags> getFlags() { |
| 347 | return flags; |
| 348 | } |
| 349 | |
| 350 | @Override |
| 351 | public OFFlowDelete.Builder setFlags(Set<OFFlowModFlags> flags) { |
| 352 | this.flags = flags; |
| 353 | this.flagsSet = true; |
| 354 | return this; |
| 355 | } |
| 356 | @Override |
| 357 | public Match getMatch() { |
| 358 | return match; |
| 359 | } |
| 360 | |
| 361 | @Override |
| 362 | public OFFlowDelete.Builder setMatch(Match match) { |
| 363 | this.match = match; |
| 364 | this.matchSet = true; |
| 365 | return this; |
| 366 | } |
| 367 | @Override |
| 368 | public List<OFInstruction> getInstructions() { |
| 369 | return instructions; |
| 370 | } |
| 371 | |
| 372 | @Override |
| 373 | public OFFlowDelete.Builder setInstructions(List<OFInstruction> instructions) { |
| 374 | this.instructions = instructions; |
| 375 | this.instructionsSet = true; |
| 376 | return this; |
| 377 | } |
| 378 | @Override |
| 379 | public List<OFAction> getActions()throws UnsupportedOperationException { |
| 380 | throw new UnsupportedOperationException("Property actions not supported in version 1.2"); |
| 381 | } |
| 382 | |
| 383 | @Override |
| 384 | public OFFlowDelete.Builder setActions(List<OFAction> actions) throws UnsupportedOperationException { |
| 385 | throw new UnsupportedOperationException("Property actions not supported in version 1.2"); |
| 386 | } |
| 387 | |
| 388 | |
| 389 | @Override |
| 390 | public OFFlowDelete build() { |
| 391 | long xid = this.xidSet ? this.xid : parentMessage.xid; |
| 392 | U64 cookie = this.cookieSet ? this.cookie : parentMessage.cookie; |
| 393 | if(cookie == null) |
| 394 | throw new NullPointerException("Property cookie must not be null"); |
| 395 | U64 cookieMask = this.cookieMaskSet ? this.cookieMask : parentMessage.cookieMask; |
| 396 | if(cookieMask == null) |
| 397 | throw new NullPointerException("Property cookieMask must not be null"); |
| 398 | TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId; |
| 399 | if(tableId == null) |
| 400 | throw new NullPointerException("Property tableId must not be null"); |
| 401 | int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : parentMessage.idleTimeout; |
| 402 | int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : parentMessage.hardTimeout; |
| 403 | int priority = this.prioritySet ? this.priority : parentMessage.priority; |
| 404 | OFBufferId bufferId = this.bufferIdSet ? this.bufferId : parentMessage.bufferId; |
| 405 | if(bufferId == null) |
| 406 | throw new NullPointerException("Property bufferId must not be null"); |
| 407 | OFPort outPort = this.outPortSet ? this.outPort : parentMessage.outPort; |
| 408 | if(outPort == null) |
| 409 | throw new NullPointerException("Property outPort must not be null"); |
| 410 | OFGroup outGroup = this.outGroupSet ? this.outGroup : parentMessage.outGroup; |
| 411 | if(outGroup == null) |
| 412 | throw new NullPointerException("Property outGroup must not be null"); |
| 413 | Set<OFFlowModFlags> flags = this.flagsSet ? this.flags : parentMessage.flags; |
| 414 | if(flags == null) |
| 415 | throw new NullPointerException("Property flags must not be null"); |
| 416 | Match match = this.matchSet ? this.match : parentMessage.match; |
| 417 | if(match == null) |
| 418 | throw new NullPointerException("Property match must not be null"); |
| 419 | List<OFInstruction> instructions = this.instructionsSet ? this.instructions : parentMessage.instructions; |
| 420 | if(instructions == null) |
| 421 | throw new NullPointerException("Property instructions must not be null"); |
| 422 | |
| 423 | // |
| 424 | return new OFFlowDeleteVer12( |
| 425 | xid, |
| 426 | cookie, |
| 427 | cookieMask, |
| 428 | tableId, |
| 429 | idleTimeout, |
| 430 | hardTimeout, |
| 431 | priority, |
| 432 | bufferId, |
| 433 | outPort, |
| 434 | outGroup, |
| 435 | flags, |
| 436 | match, |
| 437 | instructions |
| 438 | ); |
| 439 | } |
| 440 | |
| 441 | } |
| 442 | |
| 443 | static class Builder implements OFFlowDelete.Builder { |
| 444 | // OF message fields |
| 445 | private boolean xidSet; |
| 446 | private long xid; |
| 447 | private boolean cookieSet; |
| 448 | private U64 cookie; |
| 449 | private boolean cookieMaskSet; |
| 450 | private U64 cookieMask; |
| 451 | private boolean tableIdSet; |
| 452 | private TableId tableId; |
| 453 | private boolean idleTimeoutSet; |
| 454 | private int idleTimeout; |
| 455 | private boolean hardTimeoutSet; |
| 456 | private int hardTimeout; |
| 457 | private boolean prioritySet; |
| 458 | private int priority; |
| 459 | private boolean bufferIdSet; |
| 460 | private OFBufferId bufferId; |
| 461 | private boolean outPortSet; |
| 462 | private OFPort outPort; |
| 463 | private boolean outGroupSet; |
| 464 | private OFGroup outGroup; |
| 465 | private boolean flagsSet; |
| 466 | private Set<OFFlowModFlags> flags; |
| 467 | private boolean matchSet; |
| 468 | private Match match; |
| 469 | private boolean instructionsSet; |
| 470 | private List<OFInstruction> instructions; |
| 471 | |
| 472 | @Override |
| 473 | public OFVersion getVersion() { |
| 474 | return OFVersion.OF_12; |
| 475 | } |
| 476 | |
| 477 | @Override |
| 478 | public OFType getType() { |
| 479 | return OFType.FLOW_MOD; |
| 480 | } |
| 481 | |
| 482 | @Override |
| 483 | public long getXid() { |
| 484 | return xid; |
| 485 | } |
| 486 | |
| 487 | @Override |
| 488 | public OFFlowDelete.Builder setXid(long xid) { |
| 489 | this.xid = xid; |
| 490 | this.xidSet = true; |
| 491 | return this; |
| 492 | } |
| 493 | @Override |
| 494 | public U64 getCookie() { |
| 495 | return cookie; |
| 496 | } |
| 497 | |
| 498 | @Override |
| 499 | public OFFlowDelete.Builder setCookie(U64 cookie) { |
| 500 | this.cookie = cookie; |
| 501 | this.cookieSet = true; |
| 502 | return this; |
| 503 | } |
| 504 | @Override |
| 505 | public U64 getCookieMask() { |
| 506 | return cookieMask; |
| 507 | } |
| 508 | |
| 509 | @Override |
| 510 | public OFFlowDelete.Builder setCookieMask(U64 cookieMask) { |
| 511 | this.cookieMask = cookieMask; |
| 512 | this.cookieMaskSet = true; |
| 513 | return this; |
| 514 | } |
| 515 | @Override |
| 516 | public TableId getTableId() { |
| 517 | return tableId; |
| 518 | } |
| 519 | |
| 520 | @Override |
| 521 | public OFFlowDelete.Builder setTableId(TableId tableId) { |
| 522 | this.tableId = tableId; |
| 523 | this.tableIdSet = true; |
| 524 | return this; |
| 525 | } |
| 526 | @Override |
| 527 | public OFFlowModCommand getCommand() { |
| 528 | return OFFlowModCommand.DELETE; |
| 529 | } |
| 530 | |
| 531 | @Override |
| 532 | public int getIdleTimeout() { |
| 533 | return idleTimeout; |
| 534 | } |
| 535 | |
| 536 | @Override |
| 537 | public OFFlowDelete.Builder setIdleTimeout(int idleTimeout) { |
| 538 | this.idleTimeout = idleTimeout; |
| 539 | this.idleTimeoutSet = true; |
| 540 | return this; |
| 541 | } |
| 542 | @Override |
| 543 | public int getHardTimeout() { |
| 544 | return hardTimeout; |
| 545 | } |
| 546 | |
| 547 | @Override |
| 548 | public OFFlowDelete.Builder setHardTimeout(int hardTimeout) { |
| 549 | this.hardTimeout = hardTimeout; |
| 550 | this.hardTimeoutSet = true; |
| 551 | return this; |
| 552 | } |
| 553 | @Override |
| 554 | public int getPriority() { |
| 555 | return priority; |
| 556 | } |
| 557 | |
| 558 | @Override |
| 559 | public OFFlowDelete.Builder setPriority(int priority) { |
| 560 | this.priority = priority; |
| 561 | this.prioritySet = true; |
| 562 | return this; |
| 563 | } |
| 564 | @Override |
| 565 | public OFBufferId getBufferId() { |
| 566 | return bufferId; |
| 567 | } |
| 568 | |
| 569 | @Override |
| 570 | public OFFlowDelete.Builder setBufferId(OFBufferId bufferId) { |
| 571 | this.bufferId = bufferId; |
| 572 | this.bufferIdSet = true; |
| 573 | return this; |
| 574 | } |
| 575 | @Override |
| 576 | public OFPort getOutPort() { |
| 577 | return outPort; |
| 578 | } |
| 579 | |
| 580 | @Override |
| 581 | public OFFlowDelete.Builder setOutPort(OFPort outPort) { |
| 582 | this.outPort = outPort; |
| 583 | this.outPortSet = true; |
| 584 | return this; |
| 585 | } |
| 586 | @Override |
| 587 | public OFGroup getOutGroup() { |
| 588 | return outGroup; |
| 589 | } |
| 590 | |
| 591 | @Override |
| 592 | public OFFlowDelete.Builder setOutGroup(OFGroup outGroup) { |
| 593 | this.outGroup = outGroup; |
| 594 | this.outGroupSet = true; |
| 595 | return this; |
| 596 | } |
| 597 | @Override |
| 598 | public Set<OFFlowModFlags> getFlags() { |
| 599 | return flags; |
| 600 | } |
| 601 | |
| 602 | @Override |
| 603 | public OFFlowDelete.Builder setFlags(Set<OFFlowModFlags> flags) { |
| 604 | this.flags = flags; |
| 605 | this.flagsSet = true; |
| 606 | return this; |
| 607 | } |
| 608 | @Override |
| 609 | public Match getMatch() { |
| 610 | return match; |
| 611 | } |
| 612 | |
| 613 | @Override |
| 614 | public OFFlowDelete.Builder setMatch(Match match) { |
| 615 | this.match = match; |
| 616 | this.matchSet = true; |
| 617 | return this; |
| 618 | } |
| 619 | @Override |
| 620 | public List<OFInstruction> getInstructions() { |
| 621 | return instructions; |
| 622 | } |
| 623 | |
| 624 | @Override |
| 625 | public OFFlowDelete.Builder setInstructions(List<OFInstruction> instructions) { |
| 626 | this.instructions = instructions; |
| 627 | this.instructionsSet = true; |
| 628 | return this; |
| 629 | } |
| 630 | @Override |
| 631 | public List<OFAction> getActions()throws UnsupportedOperationException { |
| 632 | throw new UnsupportedOperationException("Property actions not supported in version 1.2"); |
| 633 | } |
| 634 | |
| 635 | @Override |
| 636 | public OFFlowDelete.Builder setActions(List<OFAction> actions) throws UnsupportedOperationException { |
| 637 | throw new UnsupportedOperationException("Property actions not supported in version 1.2"); |
| 638 | } |
| 639 | // |
| 640 | @Override |
| 641 | public OFFlowDelete build() { |
| 642 | long xid = this.xidSet ? this.xid : DEFAULT_XID; |
| 643 | U64 cookie = this.cookieSet ? this.cookie : DEFAULT_COOKIE; |
| 644 | if(cookie == null) |
| 645 | throw new NullPointerException("Property cookie must not be null"); |
| 646 | U64 cookieMask = this.cookieMaskSet ? this.cookieMask : DEFAULT_COOKIE_MASK; |
| 647 | if(cookieMask == null) |
| 648 | throw new NullPointerException("Property cookieMask must not be null"); |
| 649 | TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID; |
| 650 | if(tableId == null) |
| 651 | throw new NullPointerException("Property tableId must not be null"); |
| 652 | int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : DEFAULT_IDLE_TIMEOUT; |
| 653 | int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : DEFAULT_HARD_TIMEOUT; |
| 654 | int priority = this.prioritySet ? this.priority : DEFAULT_PRIORITY; |
| 655 | OFBufferId bufferId = this.bufferIdSet ? this.bufferId : DEFAULT_BUFFER_ID; |
| 656 | if(bufferId == null) |
| 657 | throw new NullPointerException("Property bufferId must not be null"); |
| 658 | OFPort outPort = this.outPortSet ? this.outPort : DEFAULT_OUT_PORT; |
| 659 | if(outPort == null) |
| 660 | throw new NullPointerException("Property outPort must not be null"); |
| 661 | OFGroup outGroup = this.outGroupSet ? this.outGroup : DEFAULT_OUT_GROUP; |
| 662 | if(outGroup == null) |
| 663 | throw new NullPointerException("Property outGroup must not be null"); |
| 664 | Set<OFFlowModFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS; |
| 665 | if(flags == null) |
| 666 | throw new NullPointerException("Property flags must not be null"); |
| 667 | Match match = this.matchSet ? this.match : DEFAULT_MATCH; |
| 668 | if(match == null) |
| 669 | throw new NullPointerException("Property match must not be null"); |
| 670 | List<OFInstruction> instructions = this.instructionsSet ? this.instructions : DEFAULT_INSTRUCTIONS; |
| 671 | if(instructions == null) |
| 672 | throw new NullPointerException("Property instructions must not be null"); |
| 673 | |
| 674 | |
| 675 | return new OFFlowDeleteVer12( |
| 676 | xid, |
| 677 | cookie, |
| 678 | cookieMask, |
| 679 | tableId, |
| 680 | idleTimeout, |
| 681 | hardTimeout, |
| 682 | priority, |
| 683 | bufferId, |
| 684 | outPort, |
| 685 | outGroup, |
| 686 | flags, |
| 687 | match, |
| 688 | instructions |
| 689 | ); |
| 690 | } |
| 691 | |
| 692 | } |
| 693 | |
| 694 | |
| 695 | final static Reader READER = new Reader(); |
| 696 | static class Reader implements OFMessageReader<OFFlowDelete> { |
| 697 | @Override |
| 698 | public OFFlowDelete readFrom(ChannelBuffer bb) throws OFParseError { |
| 699 | int start = bb.readerIndex(); |
| 700 | // fixed value property version == 3 |
| 701 | byte version = bb.readByte(); |
| 702 | if(version != (byte) 0x3) |
| 703 | throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version); |
| 704 | // fixed value property type == 14 |
| 705 | byte type = bb.readByte(); |
| 706 | if(type != (byte) 0xe) |
| 707 | throw new OFParseError("Wrong type: Expected=OFType.FLOW_MOD(14), got="+type); |
| 708 | int length = U16.f(bb.readShort()); |
| 709 | if(length < MINIMUM_LENGTH) |
| 710 | throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length); |
| 711 | if(bb.readableBytes() + (bb.readerIndex() - start) < length) { |
| 712 | // Buffer does not have all data yet |
| 713 | bb.readerIndex(start); |
| 714 | return null; |
| 715 | } |
| 716 | if(logger.isTraceEnabled()) |
| 717 | logger.trace("readFrom - length={}", length); |
| 718 | long xid = U32.f(bb.readInt()); |
| 719 | U64 cookie = U64.ofRaw(bb.readLong()); |
| 720 | U64 cookieMask = U64.ofRaw(bb.readLong()); |
| 721 | TableId tableId = TableId.readByte(bb); |
| 722 | // fixed value property command == 3 |
| 723 | short command = bb.readByte(); |
| 724 | if(command != (short) 0x3) |
| 725 | throw new OFParseError("Wrong command: Expected=OFFlowModCommand.DELETE(3), got="+command); |
| 726 | int idleTimeout = U16.f(bb.readShort()); |
| 727 | int hardTimeout = U16.f(bb.readShort()); |
| 728 | int priority = U16.f(bb.readShort()); |
| 729 | OFBufferId bufferId = OFBufferId.of(bb.readInt()); |
| 730 | OFPort outPort = OFPort.read4Bytes(bb); |
| 731 | OFGroup outGroup = OFGroup.read4Bytes(bb); |
| 732 | Set<OFFlowModFlags> flags = OFFlowModFlagsSerializerVer12.readFrom(bb); |
| 733 | // pad: 2 bytes |
| 734 | bb.skipBytes(2); |
| 735 | Match match = ChannelUtilsVer12.readOFMatch(bb); |
| 736 | List<OFInstruction> instructions = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFInstructionVer12.READER); |
| 737 | |
| 738 | OFFlowDeleteVer12 flowDeleteVer12 = new OFFlowDeleteVer12( |
| 739 | xid, |
| 740 | cookie, |
| 741 | cookieMask, |
| 742 | tableId, |
| 743 | idleTimeout, |
| 744 | hardTimeout, |
| 745 | priority, |
| 746 | bufferId, |
| 747 | outPort, |
| 748 | outGroup, |
| 749 | flags, |
| 750 | match, |
| 751 | instructions |
| 752 | ); |
| 753 | if(logger.isTraceEnabled()) |
| 754 | logger.trace("readFrom - read={}", flowDeleteVer12); |
| 755 | return flowDeleteVer12; |
| 756 | } |
| 757 | } |
| 758 | |
| 759 | public void putTo(PrimitiveSink sink) { |
| 760 | FUNNEL.funnel(this, sink); |
| 761 | } |
| 762 | |
| 763 | final static OFFlowDeleteVer12Funnel FUNNEL = new OFFlowDeleteVer12Funnel(); |
| 764 | static class OFFlowDeleteVer12Funnel implements Funnel<OFFlowDeleteVer12> { |
| 765 | private static final long serialVersionUID = 1L; |
| 766 | @Override |
| 767 | public void funnel(OFFlowDeleteVer12 message, PrimitiveSink sink) { |
| 768 | // fixed value property version = 3 |
| 769 | sink.putByte((byte) 0x3); |
| 770 | // fixed value property type = 14 |
| 771 | sink.putByte((byte) 0xe); |
| 772 | // FIXME: skip funnel of length |
| 773 | sink.putLong(message.xid); |
| 774 | message.cookie.putTo(sink); |
| 775 | message.cookieMask.putTo(sink); |
| 776 | message.tableId.putTo(sink); |
| 777 | // fixed value property command = 3 |
| 778 | sink.putShort((short) 0x3); |
| 779 | sink.putInt(message.idleTimeout); |
| 780 | sink.putInt(message.hardTimeout); |
| 781 | sink.putInt(message.priority); |
| 782 | message.bufferId.putTo(sink); |
| 783 | message.outPort.putTo(sink); |
| 784 | message.outGroup.putTo(sink); |
| 785 | OFFlowModFlagsSerializerVer12.putTo(message.flags, sink); |
| 786 | // skip pad (2 bytes) |
| 787 | message.match.putTo(sink); |
| 788 | FunnelUtils.putList(message.instructions, sink); |
| 789 | } |
| 790 | } |
| 791 | |
| 792 | |
| 793 | public void writeTo(ChannelBuffer bb) { |
| 794 | WRITER.write(bb, this); |
| 795 | } |
| 796 | |
| 797 | final static Writer WRITER = new Writer(); |
| 798 | static class Writer implements OFMessageWriter<OFFlowDeleteVer12> { |
| 799 | @Override |
| 800 | public void write(ChannelBuffer bb, OFFlowDeleteVer12 message) { |
| 801 | int startIndex = bb.writerIndex(); |
| 802 | // fixed value property version = 3 |
| 803 | bb.writeByte((byte) 0x3); |
| 804 | // fixed value property type = 14 |
| 805 | bb.writeByte((byte) 0xe); |
| 806 | // length is length of variable message, will be updated at the end |
| 807 | int lengthIndex = bb.writerIndex(); |
| 808 | bb.writeShort(U16.t(0)); |
| 809 | |
| 810 | bb.writeInt(U32.t(message.xid)); |
| 811 | bb.writeLong(message.cookie.getValue()); |
| 812 | bb.writeLong(message.cookieMask.getValue()); |
| 813 | message.tableId.writeByte(bb); |
| 814 | // fixed value property command = 3 |
| 815 | bb.writeByte((short) 0x3); |
| 816 | bb.writeShort(U16.t(message.idleTimeout)); |
| 817 | bb.writeShort(U16.t(message.hardTimeout)); |
| 818 | bb.writeShort(U16.t(message.priority)); |
| 819 | bb.writeInt(message.bufferId.getInt()); |
| 820 | message.outPort.write4Bytes(bb); |
| 821 | message.outGroup.write4Bytes(bb); |
| 822 | OFFlowModFlagsSerializerVer12.writeTo(bb, message.flags); |
| 823 | // pad: 2 bytes |
| 824 | bb.writeZero(2); |
| 825 | message.match.writeTo(bb); |
| 826 | ChannelUtils.writeList(bb, message.instructions); |
| 827 | |
| 828 | // update length field |
| 829 | int length = bb.writerIndex() - startIndex; |
| 830 | bb.setShort(lengthIndex, length); |
| 831 | |
| 832 | } |
| 833 | } |
| 834 | |
| 835 | @Override |
| 836 | public String toString() { |
| 837 | StringBuilder b = new StringBuilder("OFFlowDeleteVer12("); |
| 838 | b.append("xid=").append(xid); |
| 839 | b.append(", "); |
| 840 | b.append("cookie=").append(cookie); |
| 841 | b.append(", "); |
| 842 | b.append("cookieMask=").append(cookieMask); |
| 843 | b.append(", "); |
| 844 | b.append("tableId=").append(tableId); |
| 845 | b.append(", "); |
| 846 | b.append("idleTimeout=").append(idleTimeout); |
| 847 | b.append(", "); |
| 848 | b.append("hardTimeout=").append(hardTimeout); |
| 849 | b.append(", "); |
| 850 | b.append("priority=").append(priority); |
| 851 | b.append(", "); |
| 852 | b.append("bufferId=").append(bufferId); |
| 853 | b.append(", "); |
| 854 | b.append("outPort=").append(outPort); |
| 855 | b.append(", "); |
| 856 | b.append("outGroup=").append(outGroup); |
| 857 | b.append(", "); |
| 858 | b.append("flags=").append(flags); |
| 859 | b.append(", "); |
| 860 | b.append("match=").append(match); |
| 861 | b.append(", "); |
| 862 | b.append("instructions=").append(instructions); |
| 863 | b.append(")"); |
| 864 | return b.toString(); |
| 865 | } |
| 866 | |
| 867 | @Override |
| 868 | public boolean equals(Object obj) { |
| 869 | if (this == obj) |
| 870 | return true; |
| 871 | if (obj == null) |
| 872 | return false; |
| 873 | if (getClass() != obj.getClass()) |
| 874 | return false; |
| 875 | OFFlowDeleteVer12 other = (OFFlowDeleteVer12) obj; |
| 876 | |
| 877 | if( xid != other.xid) |
| 878 | return false; |
| 879 | if (cookie == null) { |
| 880 | if (other.cookie != null) |
| 881 | return false; |
| 882 | } else if (!cookie.equals(other.cookie)) |
| 883 | return false; |
| 884 | if (cookieMask == null) { |
| 885 | if (other.cookieMask != null) |
| 886 | return false; |
| 887 | } else if (!cookieMask.equals(other.cookieMask)) |
| 888 | return false; |
| 889 | if (tableId == null) { |
| 890 | if (other.tableId != null) |
| 891 | return false; |
| 892 | } else if (!tableId.equals(other.tableId)) |
| 893 | return false; |
| 894 | if( idleTimeout != other.idleTimeout) |
| 895 | return false; |
| 896 | if( hardTimeout != other.hardTimeout) |
| 897 | return false; |
| 898 | if( priority != other.priority) |
| 899 | return false; |
| 900 | if (bufferId == null) { |
| 901 | if (other.bufferId != null) |
| 902 | return false; |
| 903 | } else if (!bufferId.equals(other.bufferId)) |
| 904 | return false; |
| 905 | if (outPort == null) { |
| 906 | if (other.outPort != null) |
| 907 | return false; |
| 908 | } else if (!outPort.equals(other.outPort)) |
| 909 | return false; |
| 910 | if (outGroup == null) { |
| 911 | if (other.outGroup != null) |
| 912 | return false; |
| 913 | } else if (!outGroup.equals(other.outGroup)) |
| 914 | return false; |
| 915 | if (flags == null) { |
| 916 | if (other.flags != null) |
| 917 | return false; |
| 918 | } else if (!flags.equals(other.flags)) |
| 919 | return false; |
| 920 | if (match == null) { |
| 921 | if (other.match != null) |
| 922 | return false; |
| 923 | } else if (!match.equals(other.match)) |
| 924 | return false; |
| 925 | if (instructions == null) { |
| 926 | if (other.instructions != null) |
| 927 | return false; |
| 928 | } else if (!instructions.equals(other.instructions)) |
| 929 | return false; |
| 930 | return true; |
| 931 | } |
| 932 | |
| 933 | @Override |
| 934 | public int hashCode() { |
| 935 | final int prime = 31; |
| 936 | int result = 1; |
| 937 | |
| 938 | result = prime * (int) (xid ^ (xid >>> 32)); |
| 939 | result = prime * result + ((cookie == null) ? 0 : cookie.hashCode()); |
| 940 | result = prime * result + ((cookieMask == null) ? 0 : cookieMask.hashCode()); |
| 941 | result = prime * result + ((tableId == null) ? 0 : tableId.hashCode()); |
| 942 | result = prime * result + idleTimeout; |
| 943 | result = prime * result + hardTimeout; |
| 944 | result = prime * result + priority; |
| 945 | result = prime * result + ((bufferId == null) ? 0 : bufferId.hashCode()); |
| 946 | result = prime * result + ((outPort == null) ? 0 : outPort.hashCode()); |
| 947 | result = prime * result + ((outGroup == null) ? 0 : outGroup.hashCode()); |
| 948 | result = prime * result + ((flags == null) ? 0 : flags.hashCode()); |
| 949 | result = prime * result + ((match == null) ? 0 : match.hashCode()); |
| 950 | result = prime * result + ((instructions == null) ? 0 : instructions.hashCode()); |
| 951 | return result; |
| 952 | } |
| 953 | |
| 954 | } |