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.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 OFTableFeaturesVer13 implements OFTableFeatures { |
| 36 | private static final Logger logger = LoggerFactory.getLogger(OFTableFeaturesVer13.class); |
| 37 | // version: 1.3 |
| 38 | final static byte WIRE_VERSION = 4; |
| 39 | final static int MINIMUM_LENGTH = 64; |
| 40 | |
| 41 | private final static TableId DEFAULT_TABLE_ID = TableId.ALL; |
| 42 | private final static String DEFAULT_NAME = ""; |
| 43 | private final static U64 DEFAULT_METADATA_MATCH = U64.ZERO; |
| 44 | private final static U64 DEFAULT_METADATA_WRITE = U64.ZERO; |
| 45 | private final static long DEFAULT_CONFIG = 0x0L; |
| 46 | private final static long DEFAULT_MAX_ENTRIES = 0x0L; |
| 47 | private final static List<OFTableFeatureProp> DEFAULT_PROPERTIES = ImmutableList.<OFTableFeatureProp>of(); |
| 48 | |
| 49 | // OF message fields |
| 50 | private final TableId tableId; |
| 51 | private final String name; |
| 52 | private final U64 metadataMatch; |
| 53 | private final U64 metadataWrite; |
| 54 | private final long config; |
| 55 | private final long maxEntries; |
| 56 | private final List<OFTableFeatureProp> properties; |
| 57 | // |
| 58 | // Immutable default instance |
| 59 | final static OFTableFeaturesVer13 DEFAULT = new OFTableFeaturesVer13( |
| 60 | DEFAULT_TABLE_ID, DEFAULT_NAME, DEFAULT_METADATA_MATCH, DEFAULT_METADATA_WRITE, DEFAULT_CONFIG, DEFAULT_MAX_ENTRIES, DEFAULT_PROPERTIES |
| 61 | ); |
| 62 | |
| 63 | // package private constructor - used by readers, builders, and factory |
| 64 | OFTableFeaturesVer13(TableId tableId, String name, U64 metadataMatch, U64 metadataWrite, long config, long maxEntries, List<OFTableFeatureProp> properties) { |
| 65 | this.tableId = tableId; |
| 66 | this.name = name; |
| 67 | this.metadataMatch = metadataMatch; |
| 68 | this.metadataWrite = metadataWrite; |
| 69 | this.config = config; |
| 70 | this.maxEntries = maxEntries; |
| 71 | this.properties = properties; |
| 72 | } |
| 73 | |
| 74 | // Accessors for OF message fields |
| 75 | @Override |
| 76 | public TableId getTableId() { |
| 77 | return tableId; |
| 78 | } |
| 79 | |
| 80 | @Override |
| 81 | public String getName() { |
| 82 | return name; |
| 83 | } |
| 84 | |
| 85 | @Override |
| 86 | public U64 getMetadataMatch() { |
| 87 | return metadataMatch; |
| 88 | } |
| 89 | |
| 90 | @Override |
| 91 | public U64 getMetadataWrite() { |
| 92 | return metadataWrite; |
| 93 | } |
| 94 | |
| 95 | @Override |
| 96 | public long getConfig() { |
| 97 | return config; |
| 98 | } |
| 99 | |
| 100 | @Override |
| 101 | public long getMaxEntries() { |
| 102 | return maxEntries; |
| 103 | } |
| 104 | |
| 105 | @Override |
| 106 | public List<OFTableFeatureProp> getProperties() { |
| 107 | return properties; |
| 108 | } |
| 109 | |
| 110 | @Override |
| 111 | public OFVersion getVersion() { |
| 112 | return OFVersion.OF_13; |
| 113 | } |
| 114 | |
| 115 | |
| 116 | |
| 117 | public OFTableFeatures.Builder createBuilder() { |
| 118 | return new BuilderWithParent(this); |
| 119 | } |
| 120 | |
| 121 | static class BuilderWithParent implements OFTableFeatures.Builder { |
| 122 | final OFTableFeaturesVer13 parentMessage; |
| 123 | |
| 124 | // OF message fields |
| 125 | private boolean tableIdSet; |
| 126 | private TableId tableId; |
| 127 | private boolean nameSet; |
| 128 | private String name; |
| 129 | private boolean metadataMatchSet; |
| 130 | private U64 metadataMatch; |
| 131 | private boolean metadataWriteSet; |
| 132 | private U64 metadataWrite; |
| 133 | private boolean configSet; |
| 134 | private long config; |
| 135 | private boolean maxEntriesSet; |
| 136 | private long maxEntries; |
| 137 | private boolean propertiesSet; |
| 138 | private List<OFTableFeatureProp> properties; |
| 139 | |
| 140 | BuilderWithParent(OFTableFeaturesVer13 parentMessage) { |
| 141 | this.parentMessage = parentMessage; |
| 142 | } |
| 143 | |
| 144 | @Override |
| 145 | public TableId getTableId() { |
| 146 | return tableId; |
| 147 | } |
| 148 | |
| 149 | @Override |
| 150 | public OFTableFeatures.Builder setTableId(TableId tableId) { |
| 151 | this.tableId = tableId; |
| 152 | this.tableIdSet = true; |
| 153 | return this; |
| 154 | } |
| 155 | @Override |
| 156 | public String getName() { |
| 157 | return name; |
| 158 | } |
| 159 | |
| 160 | @Override |
| 161 | public OFTableFeatures.Builder setName(String name) { |
| 162 | this.name = name; |
| 163 | this.nameSet = true; |
| 164 | return this; |
| 165 | } |
| 166 | @Override |
| 167 | public U64 getMetadataMatch() { |
| 168 | return metadataMatch; |
| 169 | } |
| 170 | |
| 171 | @Override |
| 172 | public OFTableFeatures.Builder setMetadataMatch(U64 metadataMatch) { |
| 173 | this.metadataMatch = metadataMatch; |
| 174 | this.metadataMatchSet = true; |
| 175 | return this; |
| 176 | } |
| 177 | @Override |
| 178 | public U64 getMetadataWrite() { |
| 179 | return metadataWrite; |
| 180 | } |
| 181 | |
| 182 | @Override |
| 183 | public OFTableFeatures.Builder setMetadataWrite(U64 metadataWrite) { |
| 184 | this.metadataWrite = metadataWrite; |
| 185 | this.metadataWriteSet = true; |
| 186 | return this; |
| 187 | } |
| 188 | @Override |
| 189 | public long getConfig() { |
| 190 | return config; |
| 191 | } |
| 192 | |
| 193 | @Override |
| 194 | public OFTableFeatures.Builder setConfig(long config) { |
| 195 | this.config = config; |
| 196 | this.configSet = true; |
| 197 | return this; |
| 198 | } |
| 199 | @Override |
| 200 | public long getMaxEntries() { |
| 201 | return maxEntries; |
| 202 | } |
| 203 | |
| 204 | @Override |
| 205 | public OFTableFeatures.Builder setMaxEntries(long maxEntries) { |
| 206 | this.maxEntries = maxEntries; |
| 207 | this.maxEntriesSet = true; |
| 208 | return this; |
| 209 | } |
| 210 | @Override |
| 211 | public List<OFTableFeatureProp> getProperties() { |
| 212 | return properties; |
| 213 | } |
| 214 | |
| 215 | @Override |
| 216 | public OFTableFeatures.Builder setProperties(List<OFTableFeatureProp> properties) { |
| 217 | this.properties = properties; |
| 218 | this.propertiesSet = true; |
| 219 | return this; |
| 220 | } |
| 221 | @Override |
| 222 | public OFVersion getVersion() { |
| 223 | return OFVersion.OF_13; |
| 224 | } |
| 225 | |
| 226 | |
| 227 | |
| 228 | @Override |
| 229 | public OFTableFeatures build() { |
| 230 | TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId; |
| 231 | if(tableId == null) |
| 232 | throw new NullPointerException("Property tableId must not be null"); |
| 233 | String name = this.nameSet ? this.name : parentMessage.name; |
| 234 | if(name == null) |
| 235 | throw new NullPointerException("Property name must not be null"); |
| 236 | U64 metadataMatch = this.metadataMatchSet ? this.metadataMatch : parentMessage.metadataMatch; |
| 237 | if(metadataMatch == null) |
| 238 | throw new NullPointerException("Property metadataMatch must not be null"); |
| 239 | U64 metadataWrite = this.metadataWriteSet ? this.metadataWrite : parentMessage.metadataWrite; |
| 240 | if(metadataWrite == null) |
| 241 | throw new NullPointerException("Property metadataWrite must not be null"); |
| 242 | long config = this.configSet ? this.config : parentMessage.config; |
| 243 | long maxEntries = this.maxEntriesSet ? this.maxEntries : parentMessage.maxEntries; |
| 244 | List<OFTableFeatureProp> properties = this.propertiesSet ? this.properties : parentMessage.properties; |
| 245 | if(properties == null) |
| 246 | throw new NullPointerException("Property properties must not be null"); |
| 247 | |
| 248 | // |
| 249 | return new OFTableFeaturesVer13( |
| 250 | tableId, |
| 251 | name, |
| 252 | metadataMatch, |
| 253 | metadataWrite, |
| 254 | config, |
| 255 | maxEntries, |
| 256 | properties |
| 257 | ); |
| 258 | } |
| 259 | |
| 260 | } |
| 261 | |
| 262 | static class Builder implements OFTableFeatures.Builder { |
| 263 | // OF message fields |
| 264 | private boolean tableIdSet; |
| 265 | private TableId tableId; |
| 266 | private boolean nameSet; |
| 267 | private String name; |
| 268 | private boolean metadataMatchSet; |
| 269 | private U64 metadataMatch; |
| 270 | private boolean metadataWriteSet; |
| 271 | private U64 metadataWrite; |
| 272 | private boolean configSet; |
| 273 | private long config; |
| 274 | private boolean maxEntriesSet; |
| 275 | private long maxEntries; |
| 276 | private boolean propertiesSet; |
| 277 | private List<OFTableFeatureProp> properties; |
| 278 | |
| 279 | @Override |
| 280 | public TableId getTableId() { |
| 281 | return tableId; |
| 282 | } |
| 283 | |
| 284 | @Override |
| 285 | public OFTableFeatures.Builder setTableId(TableId tableId) { |
| 286 | this.tableId = tableId; |
| 287 | this.tableIdSet = true; |
| 288 | return this; |
| 289 | } |
| 290 | @Override |
| 291 | public String getName() { |
| 292 | return name; |
| 293 | } |
| 294 | |
| 295 | @Override |
| 296 | public OFTableFeatures.Builder setName(String name) { |
| 297 | this.name = name; |
| 298 | this.nameSet = true; |
| 299 | return this; |
| 300 | } |
| 301 | @Override |
| 302 | public U64 getMetadataMatch() { |
| 303 | return metadataMatch; |
| 304 | } |
| 305 | |
| 306 | @Override |
| 307 | public OFTableFeatures.Builder setMetadataMatch(U64 metadataMatch) { |
| 308 | this.metadataMatch = metadataMatch; |
| 309 | this.metadataMatchSet = true; |
| 310 | return this; |
| 311 | } |
| 312 | @Override |
| 313 | public U64 getMetadataWrite() { |
| 314 | return metadataWrite; |
| 315 | } |
| 316 | |
| 317 | @Override |
| 318 | public OFTableFeatures.Builder setMetadataWrite(U64 metadataWrite) { |
| 319 | this.metadataWrite = metadataWrite; |
| 320 | this.metadataWriteSet = true; |
| 321 | return this; |
| 322 | } |
| 323 | @Override |
| 324 | public long getConfig() { |
| 325 | return config; |
| 326 | } |
| 327 | |
| 328 | @Override |
| 329 | public OFTableFeatures.Builder setConfig(long config) { |
| 330 | this.config = config; |
| 331 | this.configSet = true; |
| 332 | return this; |
| 333 | } |
| 334 | @Override |
| 335 | public long getMaxEntries() { |
| 336 | return maxEntries; |
| 337 | } |
| 338 | |
| 339 | @Override |
| 340 | public OFTableFeatures.Builder setMaxEntries(long maxEntries) { |
| 341 | this.maxEntries = maxEntries; |
| 342 | this.maxEntriesSet = true; |
| 343 | return this; |
| 344 | } |
| 345 | @Override |
| 346 | public List<OFTableFeatureProp> getProperties() { |
| 347 | return properties; |
| 348 | } |
| 349 | |
| 350 | @Override |
| 351 | public OFTableFeatures.Builder setProperties(List<OFTableFeatureProp> properties) { |
| 352 | this.properties = properties; |
| 353 | this.propertiesSet = true; |
| 354 | return this; |
| 355 | } |
| 356 | @Override |
| 357 | public OFVersion getVersion() { |
| 358 | return OFVersion.OF_13; |
| 359 | } |
| 360 | |
| 361 | // |
| 362 | @Override |
| 363 | public OFTableFeatures build() { |
| 364 | TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID; |
| 365 | if(tableId == null) |
| 366 | throw new NullPointerException("Property tableId must not be null"); |
| 367 | String name = this.nameSet ? this.name : DEFAULT_NAME; |
| 368 | if(name == null) |
| 369 | throw new NullPointerException("Property name must not be null"); |
| 370 | U64 metadataMatch = this.metadataMatchSet ? this.metadataMatch : DEFAULT_METADATA_MATCH; |
| 371 | if(metadataMatch == null) |
| 372 | throw new NullPointerException("Property metadataMatch must not be null"); |
| 373 | U64 metadataWrite = this.metadataWriteSet ? this.metadataWrite : DEFAULT_METADATA_WRITE; |
| 374 | if(metadataWrite == null) |
| 375 | throw new NullPointerException("Property metadataWrite must not be null"); |
| 376 | long config = this.configSet ? this.config : DEFAULT_CONFIG; |
| 377 | long maxEntries = this.maxEntriesSet ? this.maxEntries : DEFAULT_MAX_ENTRIES; |
| 378 | List<OFTableFeatureProp> properties = this.propertiesSet ? this.properties : DEFAULT_PROPERTIES; |
| 379 | if(properties == null) |
| 380 | throw new NullPointerException("Property properties must not be null"); |
| 381 | |
| 382 | |
| 383 | return new OFTableFeaturesVer13( |
| 384 | tableId, |
| 385 | name, |
| 386 | metadataMatch, |
| 387 | metadataWrite, |
| 388 | config, |
| 389 | maxEntries, |
| 390 | properties |
| 391 | ); |
| 392 | } |
| 393 | |
| 394 | } |
| 395 | |
| 396 | |
| 397 | final static Reader READER = new Reader(); |
| 398 | static class Reader implements OFMessageReader<OFTableFeatures> { |
| 399 | @Override |
| 400 | public OFTableFeatures readFrom(ChannelBuffer bb) throws OFParseError { |
| 401 | int start = bb.readerIndex(); |
| 402 | int length = U16.f(bb.readShort()); |
| 403 | if(length < MINIMUM_LENGTH) |
| 404 | throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length); |
| 405 | if(bb.readableBytes() + (bb.readerIndex() - start) < length) { |
| 406 | // Buffer does not have all data yet |
| 407 | bb.readerIndex(start); |
| 408 | return null; |
| 409 | } |
| 410 | if(logger.isTraceEnabled()) |
| 411 | logger.trace("readFrom - length={}", length); |
| 412 | TableId tableId = TableId.readByte(bb); |
| 413 | // pad: 5 bytes |
| 414 | bb.skipBytes(5); |
| 415 | String name = ChannelUtils.readFixedLengthString(bb, 32); |
| 416 | U64 metadataMatch = U64.ofRaw(bb.readLong()); |
| 417 | U64 metadataWrite = U64.ofRaw(bb.readLong()); |
| 418 | long config = U32.f(bb.readInt()); |
| 419 | long maxEntries = U32.f(bb.readInt()); |
| 420 | List<OFTableFeatureProp> properties = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFTableFeaturePropVer13.READER); |
| 421 | |
| 422 | OFTableFeaturesVer13 tableFeaturesVer13 = new OFTableFeaturesVer13( |
| 423 | tableId, |
| 424 | name, |
| 425 | metadataMatch, |
| 426 | metadataWrite, |
| 427 | config, |
| 428 | maxEntries, |
| 429 | properties |
| 430 | ); |
| 431 | if(logger.isTraceEnabled()) |
| 432 | logger.trace("readFrom - read={}", tableFeaturesVer13); |
| 433 | return tableFeaturesVer13; |
| 434 | } |
| 435 | } |
| 436 | |
| 437 | public void putTo(PrimitiveSink sink) { |
| 438 | FUNNEL.funnel(this, sink); |
| 439 | } |
| 440 | |
| 441 | final static OFTableFeaturesVer13Funnel FUNNEL = new OFTableFeaturesVer13Funnel(); |
| 442 | static class OFTableFeaturesVer13Funnel implements Funnel<OFTableFeaturesVer13> { |
| 443 | private static final long serialVersionUID = 1L; |
| 444 | @Override |
| 445 | public void funnel(OFTableFeaturesVer13 message, PrimitiveSink sink) { |
| 446 | // FIXME: skip funnel of length |
| 447 | message.tableId.putTo(sink); |
| 448 | // skip pad (5 bytes) |
| 449 | sink.putUnencodedChars(message.name); |
| 450 | message.metadataMatch.putTo(sink); |
| 451 | message.metadataWrite.putTo(sink); |
| 452 | sink.putLong(message.config); |
| 453 | sink.putLong(message.maxEntries); |
| 454 | FunnelUtils.putList(message.properties, sink); |
| 455 | } |
| 456 | } |
| 457 | |
| 458 | |
| 459 | public void writeTo(ChannelBuffer bb) { |
| 460 | WRITER.write(bb, this); |
| 461 | } |
| 462 | |
| 463 | final static Writer WRITER = new Writer(); |
| 464 | static class Writer implements OFMessageWriter<OFTableFeaturesVer13> { |
| 465 | @Override |
| 466 | public void write(ChannelBuffer bb, OFTableFeaturesVer13 message) { |
| 467 | int startIndex = bb.writerIndex(); |
| 468 | // length is length of variable message, will be updated at the end |
| 469 | int lengthIndex = bb.writerIndex(); |
| 470 | bb.writeShort(U16.t(0)); |
| 471 | |
| 472 | message.tableId.writeByte(bb); |
| 473 | // pad: 5 bytes |
| 474 | bb.writeZero(5); |
| 475 | ChannelUtils.writeFixedLengthString(bb, message.name, 32); |
| 476 | bb.writeLong(message.metadataMatch.getValue()); |
| 477 | bb.writeLong(message.metadataWrite.getValue()); |
| 478 | bb.writeInt(U32.t(message.config)); |
| 479 | bb.writeInt(U32.t(message.maxEntries)); |
| 480 | ChannelUtils.writeList(bb, message.properties); |
| 481 | |
| 482 | // update length field |
| 483 | int length = bb.writerIndex() - startIndex; |
| 484 | bb.setShort(lengthIndex, length); |
| 485 | |
| 486 | } |
| 487 | } |
| 488 | |
| 489 | @Override |
| 490 | public String toString() { |
| 491 | StringBuilder b = new StringBuilder("OFTableFeaturesVer13("); |
| 492 | b.append("tableId=").append(tableId); |
| 493 | b.append(", "); |
| 494 | b.append("name=").append(name); |
| 495 | b.append(", "); |
| 496 | b.append("metadataMatch=").append(metadataMatch); |
| 497 | b.append(", "); |
| 498 | b.append("metadataWrite=").append(metadataWrite); |
| 499 | b.append(", "); |
| 500 | b.append("config=").append(config); |
| 501 | b.append(", "); |
| 502 | b.append("maxEntries=").append(maxEntries); |
| 503 | b.append(", "); |
| 504 | b.append("properties=").append(properties); |
| 505 | b.append(")"); |
| 506 | return b.toString(); |
| 507 | } |
| 508 | |
| 509 | @Override |
| 510 | public boolean equals(Object obj) { |
| 511 | if (this == obj) |
| 512 | return true; |
| 513 | if (obj == null) |
| 514 | return false; |
| 515 | if (getClass() != obj.getClass()) |
| 516 | return false; |
| 517 | OFTableFeaturesVer13 other = (OFTableFeaturesVer13) obj; |
| 518 | |
| 519 | if (tableId == null) { |
| 520 | if (other.tableId != null) |
| 521 | return false; |
| 522 | } else if (!tableId.equals(other.tableId)) |
| 523 | return false; |
| 524 | if (name == null) { |
| 525 | if (other.name != null) |
| 526 | return false; |
| 527 | } else if (!name.equals(other.name)) |
| 528 | return false; |
| 529 | if (metadataMatch == null) { |
| 530 | if (other.metadataMatch != null) |
| 531 | return false; |
| 532 | } else if (!metadataMatch.equals(other.metadataMatch)) |
| 533 | return false; |
| 534 | if (metadataWrite == null) { |
| 535 | if (other.metadataWrite != null) |
| 536 | return false; |
| 537 | } else if (!metadataWrite.equals(other.metadataWrite)) |
| 538 | return false; |
| 539 | if( config != other.config) |
| 540 | return false; |
| 541 | if( maxEntries != other.maxEntries) |
| 542 | return false; |
| 543 | if (properties == null) { |
| 544 | if (other.properties != null) |
| 545 | return false; |
| 546 | } else if (!properties.equals(other.properties)) |
| 547 | return false; |
| 548 | return true; |
| 549 | } |
| 550 | |
| 551 | @Override |
| 552 | public int hashCode() { |
| 553 | final int prime = 31; |
| 554 | int result = 1; |
| 555 | |
| 556 | result = prime * result + ((tableId == null) ? 0 : tableId.hashCode()); |
| 557 | result = prime * result + ((name == null) ? 0 : name.hashCode()); |
| 558 | result = prime * result + ((metadataMatch == null) ? 0 : metadataMatch.hashCode()); |
| 559 | result = prime * result + ((metadataWrite == null) ? 0 : metadataWrite.hashCode()); |
| 560 | result = prime * (int) (config ^ (config >>> 32)); |
| 561 | result = prime * (int) (maxEntries ^ (maxEntries >>> 32)); |
| 562 | result = prime * result + ((properties == null) ? 0 : properties.hashCode()); |
| 563 | return result; |
| 564 | } |
| 565 | |
| 566 | } |