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.ver10; |
| 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 OFTableStatsRequestVer10 implements OFTableStatsRequest { |
| 35 | private static final Logger logger = LoggerFactory.getLogger(OFTableStatsRequestVer10.class); |
| 36 | // version: 1.0 |
| 37 | final static byte WIRE_VERSION = 1; |
| 38 | final static int LENGTH = 12; |
| 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 OFTableStatsRequestVer10 DEFAULT = new OFTableStatsRequestVer10( |
| 49 | DEFAULT_XID, DEFAULT_FLAGS |
| 50 | ); |
| 51 | |
| 52 | // package private constructor - used by readers, builders, and factory |
| 53 | OFTableStatsRequestVer10(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_10; |
| 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.TABLE; |
| 77 | } |
| 78 | |
| 79 | @Override |
| 80 | public Set<OFStatsRequestFlags> getFlags() { |
| 81 | return flags; |
| 82 | } |
| 83 | |
| 84 | |
| 85 | |
| 86 | public OFTableStatsRequest.Builder createBuilder() { |
| 87 | return new BuilderWithParent(this); |
| 88 | } |
| 89 | |
| 90 | static class BuilderWithParent implements OFTableStatsRequest.Builder { |
| 91 | final OFTableStatsRequestVer10 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(OFTableStatsRequestVer10 parentMessage) { |
| 100 | this.parentMessage = parentMessage; |
| 101 | } |
| 102 | |
| 103 | @Override |
| 104 | public OFVersion getVersion() { |
| 105 | return OFVersion.OF_10; |
| 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 OFTableStatsRequest.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.TABLE; |
| 127 | } |
| 128 | |
| 129 | @Override |
| 130 | public Set<OFStatsRequestFlags> getFlags() { |
| 131 | return flags; |
| 132 | } |
| 133 | |
| 134 | @Override |
| 135 | public OFTableStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) { |
| 136 | this.flags = flags; |
| 137 | this.flagsSet = true; |
| 138 | return this; |
| 139 | } |
| 140 | |
| 141 | |
| 142 | @Override |
| 143 | public OFTableStatsRequest 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 OFTableStatsRequestVer10( |
| 151 | xid, |
| 152 | flags |
| 153 | ); |
| 154 | } |
| 155 | |
| 156 | } |
| 157 | |
| 158 | static class Builder implements OFTableStatsRequest.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_10; |
| 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 OFTableStatsRequest.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.TABLE; |
| 189 | } |
| 190 | |
| 191 | @Override |
| 192 | public Set<OFStatsRequestFlags> getFlags() { |
| 193 | return flags; |
| 194 | } |
| 195 | |
| 196 | @Override |
| 197 | public OFTableStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) { |
| 198 | this.flags = flags; |
| 199 | this.flagsSet = true; |
| 200 | return this; |
| 201 | } |
| 202 | // |
| 203 | @Override |
| 204 | public OFTableStatsRequest 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 OFTableStatsRequestVer10( |
| 212 | xid, |
| 213 | flags |
| 214 | ); |
| 215 | } |
| 216 | |
| 217 | } |
| 218 | |
| 219 | |
| 220 | final static Reader READER = new Reader(); |
| 221 | static class Reader implements OFMessageReader<OFTableStatsRequest> { |
| 222 | @Override |
| 223 | public OFTableStatsRequest readFrom(ChannelBuffer bb) throws OFParseError { |
| 224 | int start = bb.readerIndex(); |
| 225 | // fixed value property version == 1 |
| 226 | byte version = bb.readByte(); |
| 227 | if(version != (byte) 0x1) |
| 228 | throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version); |
| 229 | // fixed value property type == 16 |
| 230 | byte type = bb.readByte(); |
| 231 | if(type != (byte) 0x10) |
| 232 | throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(16), got="+type); |
| 233 | int length = U16.f(bb.readShort()); |
| 234 | if(length != 12) |
| 235 | throw new OFParseError("Wrong length: Expected=12(12), 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 == 3 |
| 245 | short statsType = bb.readShort(); |
| 246 | if(statsType != (short) 0x3) |
| 247 | throw new OFParseError("Wrong statsType: Expected=OFStatsType.TABLE(3), got="+statsType); |
| 248 | Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer10.readFrom(bb); |
| 249 | |
| 250 | OFTableStatsRequestVer10 tableStatsRequestVer10 = new OFTableStatsRequestVer10( |
| 251 | xid, |
| 252 | flags |
| 253 | ); |
| 254 | if(logger.isTraceEnabled()) |
| 255 | logger.trace("readFrom - read={}", tableStatsRequestVer10); |
| 256 | return tableStatsRequestVer10; |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | public void putTo(PrimitiveSink sink) { |
| 261 | FUNNEL.funnel(this, sink); |
| 262 | } |
| 263 | |
| 264 | final static OFTableStatsRequestVer10Funnel FUNNEL = new OFTableStatsRequestVer10Funnel(); |
| 265 | static class OFTableStatsRequestVer10Funnel implements Funnel<OFTableStatsRequestVer10> { |
| 266 | private static final long serialVersionUID = 1L; |
| 267 | @Override |
| 268 | public void funnel(OFTableStatsRequestVer10 message, PrimitiveSink sink) { |
| 269 | // fixed value property version = 1 |
| 270 | sink.putByte((byte) 0x1); |
| 271 | // fixed value property type = 16 |
| 272 | sink.putByte((byte) 0x10); |
| 273 | // fixed value property length = 12 |
| 274 | sink.putShort((short) 0xc); |
| 275 | sink.putLong(message.xid); |
| 276 | // fixed value property statsType = 3 |
| 277 | sink.putShort((short) 0x3); |
| 278 | OFStatsRequestFlagsSerializerVer10.putTo(message.flags, sink); |
| 279 | } |
| 280 | } |
| 281 | |
| 282 | |
| 283 | public void writeTo(ChannelBuffer bb) { |
| 284 | WRITER.write(bb, this); |
| 285 | } |
| 286 | |
| 287 | final static Writer WRITER = new Writer(); |
| 288 | static class Writer implements OFMessageWriter<OFTableStatsRequestVer10> { |
| 289 | @Override |
| 290 | public void write(ChannelBuffer bb, OFTableStatsRequestVer10 message) { |
| 291 | // fixed value property version = 1 |
| 292 | bb.writeByte((byte) 0x1); |
| 293 | // fixed value property type = 16 |
| 294 | bb.writeByte((byte) 0x10); |
| 295 | // fixed value property length = 12 |
| 296 | bb.writeShort((short) 0xc); |
| 297 | bb.writeInt(U32.t(message.xid)); |
| 298 | // fixed value property statsType = 3 |
| 299 | bb.writeShort((short) 0x3); |
| 300 | OFStatsRequestFlagsSerializerVer10.writeTo(bb, message.flags); |
| 301 | |
| 302 | |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | @Override |
| 307 | public String toString() { |
| 308 | StringBuilder b = new StringBuilder("OFTableStatsRequestVer10("); |
| 309 | b.append("xid=").append(xid); |
| 310 | b.append(", "); |
| 311 | b.append("flags=").append(flags); |
| 312 | b.append(")"); |
| 313 | return b.toString(); |
| 314 | } |
| 315 | |
| 316 | @Override |
| 317 | public boolean equals(Object obj) { |
| 318 | if (this == obj) |
| 319 | return true; |
| 320 | if (obj == null) |
| 321 | return false; |
| 322 | if (getClass() != obj.getClass()) |
| 323 | return false; |
| 324 | OFTableStatsRequestVer10 other = (OFTableStatsRequestVer10) obj; |
| 325 | |
| 326 | if( xid != other.xid) |
| 327 | return false; |
| 328 | if (flags == null) { |
| 329 | if (other.flags != null) |
| 330 | return false; |
| 331 | } else if (!flags.equals(other.flags)) |
| 332 | return false; |
| 333 | return true; |
| 334 | } |
| 335 | |
| 336 | @Override |
| 337 | public int hashCode() { |
| 338 | final int prime = 31; |
| 339 | int result = 1; |
| 340 | |
| 341 | result = prime * (int) (xid ^ (xid >>> 32)); |
| 342 | result = prime * result + ((flags == null) ? 0 : flags.hashCode()); |
| 343 | return result; |
| 344 | } |
| 345 | |
| 346 | } |