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