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