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