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