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