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