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