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