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