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