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