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