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.Set; |
| 29 | import org.jboss.netty.buffer.ChannelBuffer; |
| 30 | import com.google.common.hash.PrimitiveSink; |
| 31 | import com.google.common.hash.Funnel; |
| 32 | import java.util.Arrays; |
| 33 | |
| 34 | class OFBsnPduTxRequestVer10 implements OFBsnPduTxRequest { |
| 35 | private static final Logger logger = LoggerFactory.getLogger(OFBsnPduTxRequestVer10.class); |
| 36 | // version: 1.0 |
| 37 | final static byte WIRE_VERSION = 1; |
| 38 | final static int MINIMUM_LENGTH = 26; |
| 39 | |
| 40 | private final static long DEFAULT_XID = 0x0L; |
| 41 | private final static long DEFAULT_TX_INTERVAL_MS = 0x0L; |
| 42 | private final static OFPort DEFAULT_PORT_NO = OFPort.ANY; |
| 43 | private final static short DEFAULT_SLOT_NUM = (short) 0x0; |
| 44 | private final static byte[] DEFAULT_DATA = new byte[0]; |
| 45 | |
| 46 | // OF message fields |
| 47 | private final long xid; |
| 48 | private final long txIntervalMs; |
| 49 | private final OFPort portNo; |
| 50 | private final short slotNum; |
| 51 | private final byte[] data; |
| 52 | // |
| 53 | // Immutable default instance |
| 54 | final static OFBsnPduTxRequestVer10 DEFAULT = new OFBsnPduTxRequestVer10( |
| 55 | DEFAULT_XID, DEFAULT_TX_INTERVAL_MS, DEFAULT_PORT_NO, DEFAULT_SLOT_NUM, DEFAULT_DATA |
| 56 | ); |
| 57 | |
| 58 | // package private constructor - used by readers, builders, and factory |
| 59 | OFBsnPduTxRequestVer10(long xid, long txIntervalMs, OFPort portNo, short slotNum, byte[] data) { |
| 60 | this.xid = xid; |
| 61 | this.txIntervalMs = txIntervalMs; |
| 62 | this.portNo = portNo; |
| 63 | this.slotNum = slotNum; |
| 64 | this.data = data; |
| 65 | } |
| 66 | |
| 67 | // Accessors for OF message fields |
| 68 | @Override |
| 69 | public OFVersion getVersion() { |
| 70 | return OFVersion.OF_10; |
| 71 | } |
| 72 | |
| 73 | @Override |
| 74 | public OFType getType() { |
| 75 | return OFType.EXPERIMENTER; |
| 76 | } |
| 77 | |
| 78 | @Override |
| 79 | public long getXid() { |
| 80 | return xid; |
| 81 | } |
| 82 | |
| 83 | @Override |
| 84 | public long getExperimenter() { |
| 85 | return 0x5c16c7L; |
| 86 | } |
| 87 | |
| 88 | @Override |
| 89 | public long getSubtype() { |
| 90 | return 0x1fL; |
| 91 | } |
| 92 | |
| 93 | @Override |
| 94 | public long getTxIntervalMs() { |
| 95 | return txIntervalMs; |
| 96 | } |
| 97 | |
| 98 | @Override |
| 99 | public OFPort getPortNo() { |
| 100 | return portNo; |
| 101 | } |
| 102 | |
| 103 | @Override |
| 104 | public short getSlotNum() { |
| 105 | return slotNum; |
| 106 | } |
| 107 | |
| 108 | @Override |
| 109 | public byte[] getData() { |
| 110 | return data; |
| 111 | } |
| 112 | |
| 113 | |
| 114 | |
| 115 | public OFBsnPduTxRequest.Builder createBuilder() { |
| 116 | return new BuilderWithParent(this); |
| 117 | } |
| 118 | |
| 119 | static class BuilderWithParent implements OFBsnPduTxRequest.Builder { |
| 120 | final OFBsnPduTxRequestVer10 parentMessage; |
| 121 | |
| 122 | // OF message fields |
| 123 | private boolean xidSet; |
| 124 | private long xid; |
| 125 | private boolean txIntervalMsSet; |
| 126 | private long txIntervalMs; |
| 127 | private boolean portNoSet; |
| 128 | private OFPort portNo; |
| 129 | private boolean slotNumSet; |
| 130 | private short slotNum; |
| 131 | private boolean dataSet; |
| 132 | private byte[] data; |
| 133 | |
| 134 | BuilderWithParent(OFBsnPduTxRequestVer10 parentMessage) { |
| 135 | this.parentMessage = parentMessage; |
| 136 | } |
| 137 | |
| 138 | @Override |
| 139 | public OFVersion getVersion() { |
| 140 | return OFVersion.OF_10; |
| 141 | } |
| 142 | |
| 143 | @Override |
| 144 | public OFType getType() { |
| 145 | return OFType.EXPERIMENTER; |
| 146 | } |
| 147 | |
| 148 | @Override |
| 149 | public long getXid() { |
| 150 | return xid; |
| 151 | } |
| 152 | |
| 153 | @Override |
| 154 | public OFBsnPduTxRequest.Builder setXid(long xid) { |
| 155 | this.xid = xid; |
| 156 | this.xidSet = true; |
| 157 | return this; |
| 158 | } |
| 159 | @Override |
| 160 | public long getExperimenter() { |
| 161 | return 0x5c16c7L; |
| 162 | } |
| 163 | |
| 164 | @Override |
| 165 | public long getSubtype() { |
| 166 | return 0x1fL; |
| 167 | } |
| 168 | |
| 169 | @Override |
| 170 | public long getTxIntervalMs() { |
| 171 | return txIntervalMs; |
| 172 | } |
| 173 | |
| 174 | @Override |
| 175 | public OFBsnPduTxRequest.Builder setTxIntervalMs(long txIntervalMs) { |
| 176 | this.txIntervalMs = txIntervalMs; |
| 177 | this.txIntervalMsSet = true; |
| 178 | return this; |
| 179 | } |
| 180 | @Override |
| 181 | public OFPort getPortNo() { |
| 182 | return portNo; |
| 183 | } |
| 184 | |
| 185 | @Override |
| 186 | public OFBsnPduTxRequest.Builder setPortNo(OFPort portNo) { |
| 187 | this.portNo = portNo; |
| 188 | this.portNoSet = true; |
| 189 | return this; |
| 190 | } |
| 191 | @Override |
| 192 | public short getSlotNum() { |
| 193 | return slotNum; |
| 194 | } |
| 195 | |
| 196 | @Override |
| 197 | public OFBsnPduTxRequest.Builder setSlotNum(short slotNum) { |
| 198 | this.slotNum = slotNum; |
| 199 | this.slotNumSet = true; |
| 200 | return this; |
| 201 | } |
| 202 | @Override |
| 203 | public byte[] getData() { |
| 204 | return data; |
| 205 | } |
| 206 | |
| 207 | @Override |
| 208 | public OFBsnPduTxRequest.Builder setData(byte[] data) { |
| 209 | this.data = data; |
| 210 | this.dataSet = true; |
| 211 | return this; |
| 212 | } |
| 213 | |
| 214 | |
| 215 | @Override |
| 216 | public OFBsnPduTxRequest build() { |
| 217 | long xid = this.xidSet ? this.xid : parentMessage.xid; |
| 218 | long txIntervalMs = this.txIntervalMsSet ? this.txIntervalMs : parentMessage.txIntervalMs; |
| 219 | OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo; |
| 220 | if(portNo == null) |
| 221 | throw new NullPointerException("Property portNo must not be null"); |
| 222 | short slotNum = this.slotNumSet ? this.slotNum : parentMessage.slotNum; |
| 223 | byte[] data = this.dataSet ? this.data : parentMessage.data; |
| 224 | if(data == null) |
| 225 | throw new NullPointerException("Property data must not be null"); |
| 226 | |
| 227 | // |
| 228 | return new OFBsnPduTxRequestVer10( |
| 229 | xid, |
| 230 | txIntervalMs, |
| 231 | portNo, |
| 232 | slotNum, |
| 233 | data |
| 234 | ); |
| 235 | } |
| 236 | |
| 237 | } |
| 238 | |
| 239 | static class Builder implements OFBsnPduTxRequest.Builder { |
| 240 | // OF message fields |
| 241 | private boolean xidSet; |
| 242 | private long xid; |
| 243 | private boolean txIntervalMsSet; |
| 244 | private long txIntervalMs; |
| 245 | private boolean portNoSet; |
| 246 | private OFPort portNo; |
| 247 | private boolean slotNumSet; |
| 248 | private short slotNum; |
| 249 | private boolean dataSet; |
| 250 | private byte[] data; |
| 251 | |
| 252 | @Override |
| 253 | public OFVersion getVersion() { |
| 254 | return OFVersion.OF_10; |
| 255 | } |
| 256 | |
| 257 | @Override |
| 258 | public OFType getType() { |
| 259 | return OFType.EXPERIMENTER; |
| 260 | } |
| 261 | |
| 262 | @Override |
| 263 | public long getXid() { |
| 264 | return xid; |
| 265 | } |
| 266 | |
| 267 | @Override |
| 268 | public OFBsnPduTxRequest.Builder setXid(long xid) { |
| 269 | this.xid = xid; |
| 270 | this.xidSet = true; |
| 271 | return this; |
| 272 | } |
| 273 | @Override |
| 274 | public long getExperimenter() { |
| 275 | return 0x5c16c7L; |
| 276 | } |
| 277 | |
| 278 | @Override |
| 279 | public long getSubtype() { |
| 280 | return 0x1fL; |
| 281 | } |
| 282 | |
| 283 | @Override |
| 284 | public long getTxIntervalMs() { |
| 285 | return txIntervalMs; |
| 286 | } |
| 287 | |
| 288 | @Override |
| 289 | public OFBsnPduTxRequest.Builder setTxIntervalMs(long txIntervalMs) { |
| 290 | this.txIntervalMs = txIntervalMs; |
| 291 | this.txIntervalMsSet = true; |
| 292 | return this; |
| 293 | } |
| 294 | @Override |
| 295 | public OFPort getPortNo() { |
| 296 | return portNo; |
| 297 | } |
| 298 | |
| 299 | @Override |
| 300 | public OFBsnPduTxRequest.Builder setPortNo(OFPort portNo) { |
| 301 | this.portNo = portNo; |
| 302 | this.portNoSet = true; |
| 303 | return this; |
| 304 | } |
| 305 | @Override |
| 306 | public short getSlotNum() { |
| 307 | return slotNum; |
| 308 | } |
| 309 | |
| 310 | @Override |
| 311 | public OFBsnPduTxRequest.Builder setSlotNum(short slotNum) { |
| 312 | this.slotNum = slotNum; |
| 313 | this.slotNumSet = true; |
| 314 | return this; |
| 315 | } |
| 316 | @Override |
| 317 | public byte[] getData() { |
| 318 | return data; |
| 319 | } |
| 320 | |
| 321 | @Override |
| 322 | public OFBsnPduTxRequest.Builder setData(byte[] data) { |
| 323 | this.data = data; |
| 324 | this.dataSet = true; |
| 325 | return this; |
| 326 | } |
| 327 | // |
| 328 | @Override |
| 329 | public OFBsnPduTxRequest build() { |
| 330 | long xid = this.xidSet ? this.xid : DEFAULT_XID; |
| 331 | long txIntervalMs = this.txIntervalMsSet ? this.txIntervalMs : DEFAULT_TX_INTERVAL_MS; |
| 332 | OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO; |
| 333 | if(portNo == null) |
| 334 | throw new NullPointerException("Property portNo must not be null"); |
| 335 | short slotNum = this.slotNumSet ? this.slotNum : DEFAULT_SLOT_NUM; |
| 336 | byte[] data = this.dataSet ? this.data : DEFAULT_DATA; |
| 337 | if(data == null) |
| 338 | throw new NullPointerException("Property data must not be null"); |
| 339 | |
| 340 | |
| 341 | return new OFBsnPduTxRequestVer10( |
| 342 | xid, |
| 343 | txIntervalMs, |
| 344 | portNo, |
| 345 | slotNum, |
| 346 | data |
| 347 | ); |
| 348 | } |
| 349 | |
| 350 | } |
| 351 | |
| 352 | |
| 353 | final static Reader READER = new Reader(); |
| 354 | static class Reader implements OFMessageReader<OFBsnPduTxRequest> { |
| 355 | @Override |
| 356 | public OFBsnPduTxRequest readFrom(ChannelBuffer bb) throws OFParseError { |
| 357 | int start = bb.readerIndex(); |
| 358 | // fixed value property version == 1 |
| 359 | byte version = bb.readByte(); |
| 360 | if(version != (byte) 0x1) |
| 361 | throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version); |
| 362 | // fixed value property type == 4 |
| 363 | byte type = bb.readByte(); |
| 364 | if(type != (byte) 0x4) |
| 365 | throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type); |
| 366 | int length = U16.f(bb.readShort()); |
| 367 | if(length < MINIMUM_LENGTH) |
| 368 | throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length); |
| 369 | if(bb.readableBytes() + (bb.readerIndex() - start) < length) { |
| 370 | // Buffer does not have all data yet |
| 371 | bb.readerIndex(start); |
| 372 | return null; |
| 373 | } |
| 374 | if(logger.isTraceEnabled()) |
| 375 | logger.trace("readFrom - length={}", length); |
| 376 | long xid = U32.f(bb.readInt()); |
| 377 | // fixed value property experimenter == 0x5c16c7L |
| 378 | int experimenter = bb.readInt(); |
| 379 | if(experimenter != 0x5c16c7) |
| 380 | throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter); |
| 381 | // fixed value property subtype == 0x1fL |
| 382 | int subtype = bb.readInt(); |
| 383 | if(subtype != 0x1f) |
| 384 | throw new OFParseError("Wrong subtype: Expected=0x1fL(0x1fL), got="+subtype); |
| 385 | long txIntervalMs = U32.f(bb.readInt()); |
| 386 | OFPort portNo = OFPort.read2Bytes(bb); |
| 387 | short slotNum = U8.f(bb.readByte()); |
| 388 | // pad: 3 bytes |
| 389 | bb.skipBytes(3); |
| 390 | byte[] data = ChannelUtils.readBytes(bb, length - (bb.readerIndex() - start)); |
| 391 | |
| 392 | OFBsnPduTxRequestVer10 bsnPduTxRequestVer10 = new OFBsnPduTxRequestVer10( |
| 393 | xid, |
| 394 | txIntervalMs, |
| 395 | portNo, |
| 396 | slotNum, |
| 397 | data |
| 398 | ); |
| 399 | if(logger.isTraceEnabled()) |
| 400 | logger.trace("readFrom - read={}", bsnPduTxRequestVer10); |
| 401 | return bsnPduTxRequestVer10; |
| 402 | } |
| 403 | } |
| 404 | |
| 405 | public void putTo(PrimitiveSink sink) { |
| 406 | FUNNEL.funnel(this, sink); |
| 407 | } |
| 408 | |
| 409 | final static OFBsnPduTxRequestVer10Funnel FUNNEL = new OFBsnPduTxRequestVer10Funnel(); |
| 410 | static class OFBsnPduTxRequestVer10Funnel implements Funnel<OFBsnPduTxRequestVer10> { |
| 411 | private static final long serialVersionUID = 1L; |
| 412 | @Override |
| 413 | public void funnel(OFBsnPduTxRequestVer10 message, PrimitiveSink sink) { |
| 414 | // fixed value property version = 1 |
| 415 | sink.putByte((byte) 0x1); |
| 416 | // fixed value property type = 4 |
| 417 | sink.putByte((byte) 0x4); |
| 418 | // FIXME: skip funnel of length |
| 419 | sink.putLong(message.xid); |
| 420 | // fixed value property experimenter = 0x5c16c7L |
| 421 | sink.putInt(0x5c16c7); |
| 422 | // fixed value property subtype = 0x1fL |
| 423 | sink.putInt(0x1f); |
| 424 | sink.putLong(message.txIntervalMs); |
| 425 | message.portNo.putTo(sink); |
| 426 | sink.putShort(message.slotNum); |
| 427 | // skip pad (3 bytes) |
| 428 | sink.putBytes(message.data); |
| 429 | } |
| 430 | } |
| 431 | |
| 432 | |
| 433 | public void writeTo(ChannelBuffer bb) { |
| 434 | WRITER.write(bb, this); |
| 435 | } |
| 436 | |
| 437 | final static Writer WRITER = new Writer(); |
| 438 | static class Writer implements OFMessageWriter<OFBsnPduTxRequestVer10> { |
| 439 | @Override |
| 440 | public void write(ChannelBuffer bb, OFBsnPduTxRequestVer10 message) { |
| 441 | int startIndex = bb.writerIndex(); |
| 442 | // fixed value property version = 1 |
| 443 | bb.writeByte((byte) 0x1); |
| 444 | // fixed value property type = 4 |
| 445 | bb.writeByte((byte) 0x4); |
| 446 | // length is length of variable message, will be updated at the end |
| 447 | int lengthIndex = bb.writerIndex(); |
| 448 | bb.writeShort(U16.t(0)); |
| 449 | |
| 450 | bb.writeInt(U32.t(message.xid)); |
| 451 | // fixed value property experimenter = 0x5c16c7L |
| 452 | bb.writeInt(0x5c16c7); |
| 453 | // fixed value property subtype = 0x1fL |
| 454 | bb.writeInt(0x1f); |
| 455 | bb.writeInt(U32.t(message.txIntervalMs)); |
| 456 | message.portNo.write2Bytes(bb); |
| 457 | bb.writeByte(U8.t(message.slotNum)); |
| 458 | // pad: 3 bytes |
| 459 | bb.writeZero(3); |
| 460 | bb.writeBytes(message.data); |
| 461 | |
| 462 | // update length field |
| 463 | int length = bb.writerIndex() - startIndex; |
| 464 | bb.setShort(lengthIndex, length); |
| 465 | |
| 466 | } |
| 467 | } |
| 468 | |
| 469 | @Override |
| 470 | public String toString() { |
| 471 | StringBuilder b = new StringBuilder("OFBsnPduTxRequestVer10("); |
| 472 | b.append("xid=").append(xid); |
| 473 | b.append(", "); |
| 474 | b.append("txIntervalMs=").append(txIntervalMs); |
| 475 | b.append(", "); |
| 476 | b.append("portNo=").append(portNo); |
| 477 | b.append(", "); |
| 478 | b.append("slotNum=").append(slotNum); |
| 479 | b.append(", "); |
| 480 | b.append("data=").append(Arrays.toString(data)); |
| 481 | b.append(")"); |
| 482 | return b.toString(); |
| 483 | } |
| 484 | |
| 485 | @Override |
| 486 | public boolean equals(Object obj) { |
| 487 | if (this == obj) |
| 488 | return true; |
| 489 | if (obj == null) |
| 490 | return false; |
| 491 | if (getClass() != obj.getClass()) |
| 492 | return false; |
| 493 | OFBsnPduTxRequestVer10 other = (OFBsnPduTxRequestVer10) obj; |
| 494 | |
| 495 | if( xid != other.xid) |
| 496 | return false; |
| 497 | if( txIntervalMs != other.txIntervalMs) |
| 498 | return false; |
| 499 | if (portNo == null) { |
| 500 | if (other.portNo != null) |
| 501 | return false; |
| 502 | } else if (!portNo.equals(other.portNo)) |
| 503 | return false; |
| 504 | if( slotNum != other.slotNum) |
| 505 | return false; |
| 506 | if (!Arrays.equals(data, other.data)) |
| 507 | return false; |
| 508 | return true; |
| 509 | } |
| 510 | |
| 511 | @Override |
| 512 | public int hashCode() { |
| 513 | final int prime = 31; |
| 514 | int result = 1; |
| 515 | |
| 516 | result = prime * (int) (xid ^ (xid >>> 32)); |
| 517 | result = prime * (int) (txIntervalMs ^ (txIntervalMs >>> 32)); |
| 518 | result = prime * result + ((portNo == null) ? 0 : portNo.hashCode()); |
| 519 | result = prime * result + slotNum; |
| 520 | result = prime * result + Arrays.hashCode(data); |
| 521 | return result; |
| 522 | } |
| 523 | |
| 524 | } |