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