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.ver13; |
| 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 org.jboss.netty.buffer.ChannelBuffer; |
| 30 | import com.google.common.hash.PrimitiveSink; |
| 31 | import com.google.common.hash.Funnel; |
| 32 | |
| 33 | class OFBsnFlowIdleVer13 implements OFBsnFlowIdle { |
| 34 | private static final Logger logger = LoggerFactory.getLogger(OFBsnFlowIdleVer13.class); |
| 35 | // version: 1.3 |
| 36 | final static byte WIRE_VERSION = 4; |
| 37 | final static int MINIMUM_LENGTH = 40; |
| 38 | |
| 39 | private final static long DEFAULT_XID = 0x0L; |
| 40 | private final static U64 DEFAULT_COOKIE = U64.ZERO; |
| 41 | private final static int DEFAULT_PRIORITY = 0x0; |
| 42 | private final static TableId DEFAULT_TABLE_ID = TableId.ALL; |
| 43 | private final static Match DEFAULT_MATCH = OFFactoryVer13.MATCH_WILDCARD_ALL; |
| 44 | |
| 45 | // OF message fields |
| 46 | private final long xid; |
| 47 | private final U64 cookie; |
| 48 | private final int priority; |
| 49 | private final TableId tableId; |
| 50 | private final Match match; |
| 51 | // |
| 52 | // Immutable default instance |
| 53 | final static OFBsnFlowIdleVer13 DEFAULT = new OFBsnFlowIdleVer13( |
| 54 | DEFAULT_XID, DEFAULT_COOKIE, DEFAULT_PRIORITY, DEFAULT_TABLE_ID, DEFAULT_MATCH |
| 55 | ); |
| 56 | |
| 57 | // package private constructor - used by readers, builders, and factory |
| 58 | OFBsnFlowIdleVer13(long xid, U64 cookie, int priority, TableId tableId, Match match) { |
| 59 | this.xid = xid; |
| 60 | this.cookie = cookie; |
| 61 | this.priority = priority; |
| 62 | this.tableId = tableId; |
| 63 | this.match = match; |
| 64 | } |
| 65 | |
| 66 | // Accessors for OF message fields |
| 67 | @Override |
| 68 | public OFVersion getVersion() { |
| 69 | return OFVersion.OF_13; |
| 70 | } |
| 71 | |
| 72 | @Override |
| 73 | public OFType getType() { |
| 74 | return OFType.EXPERIMENTER; |
| 75 | } |
| 76 | |
| 77 | @Override |
| 78 | public long getXid() { |
| 79 | return xid; |
| 80 | } |
| 81 | |
| 82 | @Override |
| 83 | public long getExperimenter() { |
| 84 | return 0x5c16c7L; |
| 85 | } |
| 86 | |
| 87 | @Override |
| 88 | public long getSubtype() { |
| 89 | return 0x28L; |
| 90 | } |
| 91 | |
| 92 | @Override |
| 93 | public U64 getCookie() { |
| 94 | return cookie; |
| 95 | } |
| 96 | |
| 97 | @Override |
| 98 | public int getPriority() { |
| 99 | return priority; |
| 100 | } |
| 101 | |
| 102 | @Override |
| 103 | public TableId getTableId() { |
| 104 | return tableId; |
| 105 | } |
| 106 | |
| 107 | @Override |
| 108 | public Match getMatch() { |
| 109 | return match; |
| 110 | } |
| 111 | |
| 112 | |
| 113 | |
| 114 | public OFBsnFlowIdle.Builder createBuilder() { |
| 115 | return new BuilderWithParent(this); |
| 116 | } |
| 117 | |
| 118 | static class BuilderWithParent implements OFBsnFlowIdle.Builder { |
| 119 | final OFBsnFlowIdleVer13 parentMessage; |
| 120 | |
| 121 | // OF message fields |
| 122 | private boolean xidSet; |
| 123 | private long xid; |
| 124 | private boolean cookieSet; |
| 125 | private U64 cookie; |
| 126 | private boolean prioritySet; |
| 127 | private int priority; |
| 128 | private boolean tableIdSet; |
| 129 | private TableId tableId; |
| 130 | private boolean matchSet; |
| 131 | private Match match; |
| 132 | |
| 133 | BuilderWithParent(OFBsnFlowIdleVer13 parentMessage) { |
| 134 | this.parentMessage = parentMessage; |
| 135 | } |
| 136 | |
| 137 | @Override |
| 138 | public OFVersion getVersion() { |
| 139 | return OFVersion.OF_13; |
| 140 | } |
| 141 | |
| 142 | @Override |
| 143 | public OFType getType() { |
| 144 | return OFType.EXPERIMENTER; |
| 145 | } |
| 146 | |
| 147 | @Override |
| 148 | public long getXid() { |
| 149 | return xid; |
| 150 | } |
| 151 | |
| 152 | @Override |
| 153 | public OFBsnFlowIdle.Builder setXid(long xid) { |
| 154 | this.xid = xid; |
| 155 | this.xidSet = true; |
| 156 | return this; |
| 157 | } |
| 158 | @Override |
| 159 | public long getExperimenter() { |
| 160 | return 0x5c16c7L; |
| 161 | } |
| 162 | |
| 163 | @Override |
| 164 | public long getSubtype() { |
| 165 | return 0x28L; |
| 166 | } |
| 167 | |
| 168 | @Override |
| 169 | public U64 getCookie() { |
| 170 | return cookie; |
| 171 | } |
| 172 | |
| 173 | @Override |
| 174 | public OFBsnFlowIdle.Builder setCookie(U64 cookie) { |
| 175 | this.cookie = cookie; |
| 176 | this.cookieSet = true; |
| 177 | return this; |
| 178 | } |
| 179 | @Override |
| 180 | public int getPriority() { |
| 181 | return priority; |
| 182 | } |
| 183 | |
| 184 | @Override |
| 185 | public OFBsnFlowIdle.Builder setPriority(int priority) { |
| 186 | this.priority = priority; |
| 187 | this.prioritySet = true; |
| 188 | return this; |
| 189 | } |
| 190 | @Override |
| 191 | public TableId getTableId() { |
| 192 | return tableId; |
| 193 | } |
| 194 | |
| 195 | @Override |
| 196 | public OFBsnFlowIdle.Builder setTableId(TableId tableId) { |
| 197 | this.tableId = tableId; |
| 198 | this.tableIdSet = true; |
| 199 | return this; |
| 200 | } |
| 201 | @Override |
| 202 | public Match getMatch() { |
| 203 | return match; |
| 204 | } |
| 205 | |
| 206 | @Override |
| 207 | public OFBsnFlowIdle.Builder setMatch(Match match) { |
| 208 | this.match = match; |
| 209 | this.matchSet = true; |
| 210 | return this; |
| 211 | } |
| 212 | |
| 213 | |
| 214 | @Override |
| 215 | public OFBsnFlowIdle build() { |
| 216 | long xid = this.xidSet ? this.xid : parentMessage.xid; |
| 217 | U64 cookie = this.cookieSet ? this.cookie : parentMessage.cookie; |
| 218 | if(cookie == null) |
| 219 | throw new NullPointerException("Property cookie must not be null"); |
| 220 | int priority = this.prioritySet ? this.priority : parentMessage.priority; |
| 221 | TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId; |
| 222 | if(tableId == null) |
| 223 | throw new NullPointerException("Property tableId must not be null"); |
| 224 | Match match = this.matchSet ? this.match : parentMessage.match; |
| 225 | if(match == null) |
| 226 | throw new NullPointerException("Property match must not be null"); |
| 227 | |
| 228 | // |
| 229 | return new OFBsnFlowIdleVer13( |
| 230 | xid, |
| 231 | cookie, |
| 232 | priority, |
| 233 | tableId, |
| 234 | match |
| 235 | ); |
| 236 | } |
| 237 | |
| 238 | } |
| 239 | |
| 240 | static class Builder implements OFBsnFlowIdle.Builder { |
| 241 | // OF message fields |
| 242 | private boolean xidSet; |
| 243 | private long xid; |
| 244 | private boolean cookieSet; |
| 245 | private U64 cookie; |
| 246 | private boolean prioritySet; |
| 247 | private int priority; |
| 248 | private boolean tableIdSet; |
| 249 | private TableId tableId; |
| 250 | private boolean matchSet; |
| 251 | private Match match; |
| 252 | |
| 253 | @Override |
| 254 | public OFVersion getVersion() { |
| 255 | return OFVersion.OF_13; |
| 256 | } |
| 257 | |
| 258 | @Override |
| 259 | public OFType getType() { |
| 260 | return OFType.EXPERIMENTER; |
| 261 | } |
| 262 | |
| 263 | @Override |
| 264 | public long getXid() { |
| 265 | return xid; |
| 266 | } |
| 267 | |
| 268 | @Override |
| 269 | public OFBsnFlowIdle.Builder setXid(long xid) { |
| 270 | this.xid = xid; |
| 271 | this.xidSet = true; |
| 272 | return this; |
| 273 | } |
| 274 | @Override |
| 275 | public long getExperimenter() { |
| 276 | return 0x5c16c7L; |
| 277 | } |
| 278 | |
| 279 | @Override |
| 280 | public long getSubtype() { |
| 281 | return 0x28L; |
| 282 | } |
| 283 | |
| 284 | @Override |
| 285 | public U64 getCookie() { |
| 286 | return cookie; |
| 287 | } |
| 288 | |
| 289 | @Override |
| 290 | public OFBsnFlowIdle.Builder setCookie(U64 cookie) { |
| 291 | this.cookie = cookie; |
| 292 | this.cookieSet = true; |
| 293 | return this; |
| 294 | } |
| 295 | @Override |
| 296 | public int getPriority() { |
| 297 | return priority; |
| 298 | } |
| 299 | |
| 300 | @Override |
| 301 | public OFBsnFlowIdle.Builder setPriority(int priority) { |
| 302 | this.priority = priority; |
| 303 | this.prioritySet = true; |
| 304 | return this; |
| 305 | } |
| 306 | @Override |
| 307 | public TableId getTableId() { |
| 308 | return tableId; |
| 309 | } |
| 310 | |
| 311 | @Override |
| 312 | public OFBsnFlowIdle.Builder setTableId(TableId tableId) { |
| 313 | this.tableId = tableId; |
| 314 | this.tableIdSet = true; |
| 315 | return this; |
| 316 | } |
| 317 | @Override |
| 318 | public Match getMatch() { |
| 319 | return match; |
| 320 | } |
| 321 | |
| 322 | @Override |
| 323 | public OFBsnFlowIdle.Builder setMatch(Match match) { |
| 324 | this.match = match; |
| 325 | this.matchSet = true; |
| 326 | return this; |
| 327 | } |
| 328 | // |
| 329 | @Override |
| 330 | public OFBsnFlowIdle build() { |
| 331 | long xid = this.xidSet ? this.xid : DEFAULT_XID; |
| 332 | U64 cookie = this.cookieSet ? this.cookie : DEFAULT_COOKIE; |
| 333 | if(cookie == null) |
| 334 | throw new NullPointerException("Property cookie must not be null"); |
| 335 | int priority = this.prioritySet ? this.priority : DEFAULT_PRIORITY; |
| 336 | TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID; |
| 337 | if(tableId == null) |
| 338 | throw new NullPointerException("Property tableId must not be null"); |
| 339 | Match match = this.matchSet ? this.match : DEFAULT_MATCH; |
| 340 | if(match == null) |
| 341 | throw new NullPointerException("Property match must not be null"); |
| 342 | |
| 343 | |
| 344 | return new OFBsnFlowIdleVer13( |
| 345 | xid, |
| 346 | cookie, |
| 347 | priority, |
| 348 | tableId, |
| 349 | match |
| 350 | ); |
| 351 | } |
| 352 | |
| 353 | } |
| 354 | |
| 355 | |
| 356 | final static Reader READER = new Reader(); |
| 357 | static class Reader implements OFMessageReader<OFBsnFlowIdle> { |
| 358 | @Override |
| 359 | public OFBsnFlowIdle readFrom(ChannelBuffer bb) throws OFParseError { |
| 360 | int start = bb.readerIndex(); |
| 361 | // fixed value property version == 4 |
| 362 | byte version = bb.readByte(); |
| 363 | if(version != (byte) 0x4) |
| 364 | throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version); |
| 365 | // fixed value property type == 4 |
| 366 | byte type = bb.readByte(); |
| 367 | if(type != (byte) 0x4) |
| 368 | throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type); |
| 369 | int length = U16.f(bb.readShort()); |
| 370 | if(length < MINIMUM_LENGTH) |
| 371 | throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length); |
| 372 | if(bb.readableBytes() + (bb.readerIndex() - start) < length) { |
| 373 | // Buffer does not have all data yet |
| 374 | bb.readerIndex(start); |
| 375 | return null; |
| 376 | } |
| 377 | if(logger.isTraceEnabled()) |
| 378 | logger.trace("readFrom - length={}", length); |
| 379 | long xid = U32.f(bb.readInt()); |
| 380 | // fixed value property experimenter == 0x5c16c7L |
| 381 | int experimenter = bb.readInt(); |
| 382 | if(experimenter != 0x5c16c7) |
| 383 | throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter); |
| 384 | // fixed value property subtype == 0x28L |
| 385 | int subtype = bb.readInt(); |
| 386 | if(subtype != 0x28) |
| 387 | throw new OFParseError("Wrong subtype: Expected=0x28L(0x28L), got="+subtype); |
| 388 | U64 cookie = U64.ofRaw(bb.readLong()); |
| 389 | int priority = U16.f(bb.readShort()); |
| 390 | TableId tableId = TableId.readByte(bb); |
| 391 | // pad: 5 bytes |
| 392 | bb.skipBytes(5); |
| 393 | Match match = ChannelUtilsVer13.readOFMatch(bb); |
| 394 | |
| 395 | OFBsnFlowIdleVer13 bsnFlowIdleVer13 = new OFBsnFlowIdleVer13( |
| 396 | xid, |
| 397 | cookie, |
| 398 | priority, |
| 399 | tableId, |
| 400 | match |
| 401 | ); |
| 402 | if(logger.isTraceEnabled()) |
| 403 | logger.trace("readFrom - read={}", bsnFlowIdleVer13); |
| 404 | return bsnFlowIdleVer13; |
| 405 | } |
| 406 | } |
| 407 | |
| 408 | public void putTo(PrimitiveSink sink) { |
| 409 | FUNNEL.funnel(this, sink); |
| 410 | } |
| 411 | |
| 412 | final static OFBsnFlowIdleVer13Funnel FUNNEL = new OFBsnFlowIdleVer13Funnel(); |
| 413 | static class OFBsnFlowIdleVer13Funnel implements Funnel<OFBsnFlowIdleVer13> { |
| 414 | private static final long serialVersionUID = 1L; |
| 415 | @Override |
| 416 | public void funnel(OFBsnFlowIdleVer13 message, PrimitiveSink sink) { |
| 417 | // fixed value property version = 4 |
| 418 | sink.putByte((byte) 0x4); |
| 419 | // fixed value property type = 4 |
| 420 | sink.putByte((byte) 0x4); |
| 421 | // FIXME: skip funnel of length |
| 422 | sink.putLong(message.xid); |
| 423 | // fixed value property experimenter = 0x5c16c7L |
| 424 | sink.putInt(0x5c16c7); |
| 425 | // fixed value property subtype = 0x28L |
| 426 | sink.putInt(0x28); |
| 427 | message.cookie.putTo(sink); |
| 428 | sink.putInt(message.priority); |
| 429 | message.tableId.putTo(sink); |
| 430 | // skip pad (5 bytes) |
| 431 | message.match.putTo(sink); |
| 432 | } |
| 433 | } |
| 434 | |
| 435 | |
| 436 | public void writeTo(ChannelBuffer bb) { |
| 437 | WRITER.write(bb, this); |
| 438 | } |
| 439 | |
| 440 | final static Writer WRITER = new Writer(); |
| 441 | static class Writer implements OFMessageWriter<OFBsnFlowIdleVer13> { |
| 442 | @Override |
| 443 | public void write(ChannelBuffer bb, OFBsnFlowIdleVer13 message) { |
| 444 | int startIndex = bb.writerIndex(); |
| 445 | // fixed value property version = 4 |
| 446 | bb.writeByte((byte) 0x4); |
| 447 | // fixed value property type = 4 |
| 448 | bb.writeByte((byte) 0x4); |
| 449 | // length is length of variable message, will be updated at the end |
| 450 | int lengthIndex = bb.writerIndex(); |
| 451 | bb.writeShort(U16.t(0)); |
| 452 | |
| 453 | bb.writeInt(U32.t(message.xid)); |
| 454 | // fixed value property experimenter = 0x5c16c7L |
| 455 | bb.writeInt(0x5c16c7); |
| 456 | // fixed value property subtype = 0x28L |
| 457 | bb.writeInt(0x28); |
| 458 | bb.writeLong(message.cookie.getValue()); |
| 459 | bb.writeShort(U16.t(message.priority)); |
| 460 | message.tableId.writeByte(bb); |
| 461 | // pad: 5 bytes |
| 462 | bb.writeZero(5); |
| 463 | message.match.writeTo(bb); |
| 464 | |
| 465 | // update length field |
| 466 | int length = bb.writerIndex() - startIndex; |
| 467 | bb.setShort(lengthIndex, length); |
| 468 | |
| 469 | } |
| 470 | } |
| 471 | |
| 472 | @Override |
| 473 | public String toString() { |
| 474 | StringBuilder b = new StringBuilder("OFBsnFlowIdleVer13("); |
| 475 | b.append("xid=").append(xid); |
| 476 | b.append(", "); |
| 477 | b.append("cookie=").append(cookie); |
| 478 | b.append(", "); |
| 479 | b.append("priority=").append(priority); |
| 480 | b.append(", "); |
| 481 | b.append("tableId=").append(tableId); |
| 482 | b.append(", "); |
| 483 | b.append("match=").append(match); |
| 484 | b.append(")"); |
| 485 | return b.toString(); |
| 486 | } |
| 487 | |
| 488 | @Override |
| 489 | public boolean equals(Object obj) { |
| 490 | if (this == obj) |
| 491 | return true; |
| 492 | if (obj == null) |
| 493 | return false; |
| 494 | if (getClass() != obj.getClass()) |
| 495 | return false; |
| 496 | OFBsnFlowIdleVer13 other = (OFBsnFlowIdleVer13) obj; |
| 497 | |
| 498 | if( xid != other.xid) |
| 499 | return false; |
| 500 | if (cookie == null) { |
| 501 | if (other.cookie != null) |
| 502 | return false; |
| 503 | } else if (!cookie.equals(other.cookie)) |
| 504 | return false; |
| 505 | if( priority != other.priority) |
| 506 | return false; |
| 507 | if (tableId == null) { |
| 508 | if (other.tableId != null) |
| 509 | return false; |
| 510 | } else if (!tableId.equals(other.tableId)) |
| 511 | return false; |
| 512 | if (match == null) { |
| 513 | if (other.match != null) |
| 514 | return false; |
| 515 | } else if (!match.equals(other.match)) |
| 516 | return false; |
| 517 | return true; |
| 518 | } |
| 519 | |
| 520 | @Override |
| 521 | public int hashCode() { |
| 522 | final int prime = 31; |
| 523 | int result = 1; |
| 524 | |
| 525 | result = prime * (int) (xid ^ (xid >>> 32)); |
| 526 | result = prime * result + ((cookie == null) ? 0 : cookie.hashCode()); |
| 527 | result = prime * result + priority; |
| 528 | result = prime * result + ((tableId == null) ? 0 : tableId.hashCode()); |
| 529 | result = prime * result + ((match == null) ? 0 : match.hashCode()); |
| 530 | return result; |
| 531 | } |
| 532 | |
| 533 | } |