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