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