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