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