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