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