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