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