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