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