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