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