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.ver11; |
| 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 OFAggregateStatsReplyVer11 implements OFAggregateStatsReply { |
| 35 | private static final Logger logger = LoggerFactory.getLogger(OFAggregateStatsReplyVer11.class); |
| 36 | // version: 1.1 |
| 37 | final static byte WIRE_VERSION = 2; |
| 38 | final static int LENGTH = 40; |
| 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 OFAggregateStatsReplyVer11 DEFAULT = new OFAggregateStatsReplyVer11( |
| 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 | OFAggregateStatsReplyVer11(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_11; |
| 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 OFAggregateStatsReplyVer11 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(OFAggregateStatsReplyVer11 parentMessage) { |
| 130 | this.parentMessage = parentMessage; |
| 131 | } |
| 132 | |
| 133 | @Override |
| 134 | public OFVersion getVersion() { |
| 135 | return OFVersion.OF_11; |
| 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 OFAggregateStatsReplyVer11( |
| 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_11; |
| 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 OFAggregateStatsReplyVer11( |
| 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 == 2 |
| 348 | byte version = bb.readByte(); |
| 349 | if(version != (byte) 0x2) |
| 350 | throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version); |
| 351 | // fixed value property type == 19 |
| 352 | byte type = bb.readByte(); |
| 353 | if(type != (byte) 0x13) |
| 354 | throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type); |
| 355 | int length = U16.f(bb.readShort()); |
| 356 | if(length != 40) |
| 357 | throw new OFParseError("Wrong length: Expected=40(40), 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 = OFStatsReplyFlagsSerializerVer11.readFrom(bb); |
| 371 | // pad: 4 bytes |
| 372 | bb.skipBytes(4); |
| 373 | U64 packetCount = U64.ofRaw(bb.readLong()); |
| 374 | U64 byteCount = U64.ofRaw(bb.readLong()); |
| 375 | long flowCount = U32.f(bb.readInt()); |
| 376 | // pad: 4 bytes |
| 377 | bb.skipBytes(4); |
| 378 | |
| 379 | OFAggregateStatsReplyVer11 aggregateStatsReplyVer11 = new OFAggregateStatsReplyVer11( |
| 380 | xid, |
| 381 | flags, |
| 382 | packetCount, |
| 383 | byteCount, |
| 384 | flowCount |
| 385 | ); |
| 386 | if(logger.isTraceEnabled()) |
| 387 | logger.trace("readFrom - read={}", aggregateStatsReplyVer11); |
| 388 | return aggregateStatsReplyVer11; |
| 389 | } |
| 390 | } |
| 391 | |
| 392 | public void putTo(PrimitiveSink sink) { |
| 393 | FUNNEL.funnel(this, sink); |
| 394 | } |
| 395 | |
| 396 | final static OFAggregateStatsReplyVer11Funnel FUNNEL = new OFAggregateStatsReplyVer11Funnel(); |
| 397 | static class OFAggregateStatsReplyVer11Funnel implements Funnel<OFAggregateStatsReplyVer11> { |
| 398 | private static final long serialVersionUID = 1L; |
| 399 | @Override |
| 400 | public void funnel(OFAggregateStatsReplyVer11 message, PrimitiveSink sink) { |
| 401 | // fixed value property version = 2 |
| 402 | sink.putByte((byte) 0x2); |
| 403 | // fixed value property type = 19 |
| 404 | sink.putByte((byte) 0x13); |
| 405 | // fixed value property length = 40 |
| 406 | sink.putShort((short) 0x28); |
| 407 | sink.putLong(message.xid); |
| 408 | // fixed value property statsType = 2 |
| 409 | sink.putShort((short) 0x2); |
| 410 | OFStatsReplyFlagsSerializerVer11.putTo(message.flags, sink); |
| 411 | // skip pad (4 bytes) |
| 412 | message.packetCount.putTo(sink); |
| 413 | message.byteCount.putTo(sink); |
| 414 | sink.putLong(message.flowCount); |
| 415 | // skip pad (4 bytes) |
| 416 | } |
| 417 | } |
| 418 | |
| 419 | |
| 420 | public void writeTo(ChannelBuffer bb) { |
| 421 | WRITER.write(bb, this); |
| 422 | } |
| 423 | |
| 424 | final static Writer WRITER = new Writer(); |
| 425 | static class Writer implements OFMessageWriter<OFAggregateStatsReplyVer11> { |
| 426 | @Override |
| 427 | public void write(ChannelBuffer bb, OFAggregateStatsReplyVer11 message) { |
| 428 | // fixed value property version = 2 |
| 429 | bb.writeByte((byte) 0x2); |
| 430 | // fixed value property type = 19 |
| 431 | bb.writeByte((byte) 0x13); |
| 432 | // fixed value property length = 40 |
| 433 | bb.writeShort((short) 0x28); |
| 434 | bb.writeInt(U32.t(message.xid)); |
| 435 | // fixed value property statsType = 2 |
| 436 | bb.writeShort((short) 0x2); |
| 437 | OFStatsReplyFlagsSerializerVer11.writeTo(bb, message.flags); |
| 438 | // pad: 4 bytes |
| 439 | bb.writeZero(4); |
| 440 | bb.writeLong(message.packetCount.getValue()); |
| 441 | bb.writeLong(message.byteCount.getValue()); |
| 442 | bb.writeInt(U32.t(message.flowCount)); |
| 443 | // pad: 4 bytes |
| 444 | bb.writeZero(4); |
| 445 | |
| 446 | |
| 447 | } |
| 448 | } |
| 449 | |
| 450 | @Override |
| 451 | public String toString() { |
| 452 | StringBuilder b = new StringBuilder("OFAggregateStatsReplyVer11("); |
| 453 | b.append("xid=").append(xid); |
| 454 | b.append(", "); |
| 455 | b.append("flags=").append(flags); |
| 456 | b.append(", "); |
| 457 | b.append("packetCount=").append(packetCount); |
| 458 | b.append(", "); |
| 459 | b.append("byteCount=").append(byteCount); |
| 460 | b.append(", "); |
| 461 | b.append("flowCount=").append(flowCount); |
| 462 | b.append(")"); |
| 463 | return b.toString(); |
| 464 | } |
| 465 | |
| 466 | @Override |
| 467 | public boolean equals(Object obj) { |
| 468 | if (this == obj) |
| 469 | return true; |
| 470 | if (obj == null) |
| 471 | return false; |
| 472 | if (getClass() != obj.getClass()) |
| 473 | return false; |
| 474 | OFAggregateStatsReplyVer11 other = (OFAggregateStatsReplyVer11) obj; |
| 475 | |
| 476 | if( xid != other.xid) |
| 477 | return false; |
| 478 | if (flags == null) { |
| 479 | if (other.flags != null) |
| 480 | return false; |
| 481 | } else if (!flags.equals(other.flags)) |
| 482 | return false; |
| 483 | if (packetCount == null) { |
| 484 | if (other.packetCount != null) |
| 485 | return false; |
| 486 | } else if (!packetCount.equals(other.packetCount)) |
| 487 | return false; |
| 488 | if (byteCount == null) { |
| 489 | if (other.byteCount != null) |
| 490 | return false; |
| 491 | } else if (!byteCount.equals(other.byteCount)) |
| 492 | return false; |
| 493 | if( flowCount != other.flowCount) |
| 494 | return false; |
| 495 | return true; |
| 496 | } |
| 497 | |
| 498 | @Override |
| 499 | public int hashCode() { |
| 500 | final int prime = 31; |
| 501 | int result = 1; |
| 502 | |
| 503 | result = prime * (int) (xid ^ (xid >>> 32)); |
| 504 | result = prime * result + ((flags == null) ? 0 : flags.hashCode()); |
| 505 | result = prime * result + ((packetCount == null) ? 0 : packetCount.hashCode()); |
| 506 | result = prime * result + ((byteCount == null) ? 0 : byteCount.hashCode()); |
| 507 | result = prime * (int) (flowCount ^ (flowCount >>> 32)); |
| 508 | return result; |
| 509 | } |
| 510 | |
| 511 | } |