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.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 com.google.common.collect.ImmutableSet; |
| 30 | import org.jboss.netty.buffer.ChannelBuffer; |
| 31 | import com.google.common.hash.PrimitiveSink; |
| 32 | import com.google.common.hash.Funnel; |
| 33 | |
| 34 | class OFPortDescVer11 implements OFPortDesc { |
| 35 | private static final Logger logger = LoggerFactory.getLogger(OFPortDescVer11.class); |
| 36 | // version: 1.1 |
| 37 | final static byte WIRE_VERSION = 2; |
| 38 | final static int LENGTH = 64; |
| 39 | |
| 40 | private final static OFPort DEFAULT_PORT_NO = OFPort.ANY; |
| 41 | private final static MacAddress DEFAULT_HW_ADDR = MacAddress.NONE; |
| 42 | private final static String DEFAULT_NAME = ""; |
| 43 | private final static Set<OFPortConfig> DEFAULT_CONFIG = ImmutableSet.<OFPortConfig>of(); |
| 44 | private final static Set<OFPortState> DEFAULT_STATE = ImmutableSet.<OFPortState>of(); |
| 45 | private final static Set<OFPortFeatures> DEFAULT_CURR = ImmutableSet.<OFPortFeatures>of(); |
| 46 | private final static Set<OFPortFeatures> DEFAULT_ADVERTISED = ImmutableSet.<OFPortFeatures>of(); |
| 47 | private final static Set<OFPortFeatures> DEFAULT_SUPPORTED = ImmutableSet.<OFPortFeatures>of(); |
| 48 | private final static Set<OFPortFeatures> DEFAULT_PEER = ImmutableSet.<OFPortFeatures>of(); |
| 49 | private final static long DEFAULT_CURR_SPEED = 0x0L; |
| 50 | private final static long DEFAULT_MAX_SPEED = 0x0L; |
| 51 | |
| 52 | // OF message fields |
| 53 | private final OFPort portNo; |
| 54 | private final MacAddress hwAddr; |
| 55 | private final String name; |
| 56 | private final Set<OFPortConfig> config; |
| 57 | private final Set<OFPortState> state; |
| 58 | private final Set<OFPortFeatures> curr; |
| 59 | private final Set<OFPortFeatures> advertised; |
| 60 | private final Set<OFPortFeatures> supported; |
| 61 | private final Set<OFPortFeatures> peer; |
| 62 | private final long currSpeed; |
| 63 | private final long maxSpeed; |
| 64 | // |
| 65 | // Immutable default instance |
| 66 | final static OFPortDescVer11 DEFAULT = new OFPortDescVer11( |
| 67 | DEFAULT_PORT_NO, DEFAULT_HW_ADDR, DEFAULT_NAME, DEFAULT_CONFIG, DEFAULT_STATE, DEFAULT_CURR, DEFAULT_ADVERTISED, DEFAULT_SUPPORTED, DEFAULT_PEER, DEFAULT_CURR_SPEED, DEFAULT_MAX_SPEED |
| 68 | ); |
| 69 | |
| 70 | // package private constructor - used by readers, builders, and factory |
| 71 | OFPortDescVer11(OFPort portNo, MacAddress hwAddr, String name, Set<OFPortConfig> config, Set<OFPortState> state, Set<OFPortFeatures> curr, Set<OFPortFeatures> advertised, Set<OFPortFeatures> supported, Set<OFPortFeatures> peer, long currSpeed, long maxSpeed) { |
| 72 | this.portNo = portNo; |
| 73 | this.hwAddr = hwAddr; |
| 74 | this.name = name; |
| 75 | this.config = config; |
| 76 | this.state = state; |
| 77 | this.curr = curr; |
| 78 | this.advertised = advertised; |
| 79 | this.supported = supported; |
| 80 | this.peer = peer; |
| 81 | this.currSpeed = currSpeed; |
| 82 | this.maxSpeed = maxSpeed; |
| 83 | } |
| 84 | |
| 85 | // Accessors for OF message fields |
| 86 | @Override |
| 87 | public OFPort getPortNo() { |
| 88 | return portNo; |
| 89 | } |
| 90 | |
| 91 | @Override |
| 92 | public MacAddress getHwAddr() { |
| 93 | return hwAddr; |
| 94 | } |
| 95 | |
| 96 | @Override |
| 97 | public String getName() { |
| 98 | return name; |
| 99 | } |
| 100 | |
| 101 | @Override |
| 102 | public Set<OFPortConfig> getConfig() { |
| 103 | return config; |
| 104 | } |
| 105 | |
| 106 | @Override |
| 107 | public Set<OFPortState> getState() { |
| 108 | return state; |
| 109 | } |
| 110 | |
| 111 | @Override |
| 112 | public Set<OFPortFeatures> getCurr() { |
| 113 | return curr; |
| 114 | } |
| 115 | |
| 116 | @Override |
| 117 | public Set<OFPortFeatures> getAdvertised() { |
| 118 | return advertised; |
| 119 | } |
| 120 | |
| 121 | @Override |
| 122 | public Set<OFPortFeatures> getSupported() { |
| 123 | return supported; |
| 124 | } |
| 125 | |
| 126 | @Override |
| 127 | public Set<OFPortFeatures> getPeer() { |
| 128 | return peer; |
| 129 | } |
| 130 | |
| 131 | @Override |
| 132 | public long getCurrSpeed() { |
| 133 | return currSpeed; |
| 134 | } |
| 135 | |
| 136 | @Override |
| 137 | public long getMaxSpeed() { |
| 138 | return maxSpeed; |
| 139 | } |
| 140 | |
| 141 | @Override |
| 142 | public OFVersion getVersion() { |
| 143 | return OFVersion.OF_11; |
| 144 | } |
| 145 | |
| 146 | |
| 147 | |
| 148 | public OFPortDesc.Builder createBuilder() { |
| 149 | return new BuilderWithParent(this); |
| 150 | } |
| 151 | |
| 152 | static class BuilderWithParent implements OFPortDesc.Builder { |
| 153 | final OFPortDescVer11 parentMessage; |
| 154 | |
| 155 | // OF message fields |
| 156 | private boolean portNoSet; |
| 157 | private OFPort portNo; |
| 158 | private boolean hwAddrSet; |
| 159 | private MacAddress hwAddr; |
| 160 | private boolean nameSet; |
| 161 | private String name; |
| 162 | private boolean configSet; |
| 163 | private Set<OFPortConfig> config; |
| 164 | private boolean stateSet; |
| 165 | private Set<OFPortState> state; |
| 166 | private boolean currSet; |
| 167 | private Set<OFPortFeatures> curr; |
| 168 | private boolean advertisedSet; |
| 169 | private Set<OFPortFeatures> advertised; |
| 170 | private boolean supportedSet; |
| 171 | private Set<OFPortFeatures> supported; |
| 172 | private boolean peerSet; |
| 173 | private Set<OFPortFeatures> peer; |
| 174 | private boolean currSpeedSet; |
| 175 | private long currSpeed; |
| 176 | private boolean maxSpeedSet; |
| 177 | private long maxSpeed; |
| 178 | |
| 179 | BuilderWithParent(OFPortDescVer11 parentMessage) { |
| 180 | this.parentMessage = parentMessage; |
| 181 | } |
| 182 | |
| 183 | @Override |
| 184 | public OFPort getPortNo() { |
| 185 | return portNo; |
| 186 | } |
| 187 | |
| 188 | @Override |
| 189 | public OFPortDesc.Builder setPortNo(OFPort portNo) { |
| 190 | this.portNo = portNo; |
| 191 | this.portNoSet = true; |
| 192 | return this; |
| 193 | } |
| 194 | @Override |
| 195 | public MacAddress getHwAddr() { |
| 196 | return hwAddr; |
| 197 | } |
| 198 | |
| 199 | @Override |
| 200 | public OFPortDesc.Builder setHwAddr(MacAddress hwAddr) { |
| 201 | this.hwAddr = hwAddr; |
| 202 | this.hwAddrSet = true; |
| 203 | return this; |
| 204 | } |
| 205 | @Override |
| 206 | public String getName() { |
| 207 | return name; |
| 208 | } |
| 209 | |
| 210 | @Override |
| 211 | public OFPortDesc.Builder setName(String name) { |
| 212 | this.name = name; |
| 213 | this.nameSet = true; |
| 214 | return this; |
| 215 | } |
| 216 | @Override |
| 217 | public Set<OFPortConfig> getConfig() { |
| 218 | return config; |
| 219 | } |
| 220 | |
| 221 | @Override |
| 222 | public OFPortDesc.Builder setConfig(Set<OFPortConfig> config) { |
| 223 | this.config = config; |
| 224 | this.configSet = true; |
| 225 | return this; |
| 226 | } |
| 227 | @Override |
| 228 | public Set<OFPortState> getState() { |
| 229 | return state; |
| 230 | } |
| 231 | |
| 232 | @Override |
| 233 | public OFPortDesc.Builder setState(Set<OFPortState> state) { |
| 234 | this.state = state; |
| 235 | this.stateSet = true; |
| 236 | return this; |
| 237 | } |
| 238 | @Override |
| 239 | public Set<OFPortFeatures> getCurr() { |
| 240 | return curr; |
| 241 | } |
| 242 | |
| 243 | @Override |
| 244 | public OFPortDesc.Builder setCurr(Set<OFPortFeatures> curr) { |
| 245 | this.curr = curr; |
| 246 | this.currSet = true; |
| 247 | return this; |
| 248 | } |
| 249 | @Override |
| 250 | public Set<OFPortFeatures> getAdvertised() { |
| 251 | return advertised; |
| 252 | } |
| 253 | |
| 254 | @Override |
| 255 | public OFPortDesc.Builder setAdvertised(Set<OFPortFeatures> advertised) { |
| 256 | this.advertised = advertised; |
| 257 | this.advertisedSet = true; |
| 258 | return this; |
| 259 | } |
| 260 | @Override |
| 261 | public Set<OFPortFeatures> getSupported() { |
| 262 | return supported; |
| 263 | } |
| 264 | |
| 265 | @Override |
| 266 | public OFPortDesc.Builder setSupported(Set<OFPortFeatures> supported) { |
| 267 | this.supported = supported; |
| 268 | this.supportedSet = true; |
| 269 | return this; |
| 270 | } |
| 271 | @Override |
| 272 | public Set<OFPortFeatures> getPeer() { |
| 273 | return peer; |
| 274 | } |
| 275 | |
| 276 | @Override |
| 277 | public OFPortDesc.Builder setPeer(Set<OFPortFeatures> peer) { |
| 278 | this.peer = peer; |
| 279 | this.peerSet = true; |
| 280 | return this; |
| 281 | } |
| 282 | @Override |
| 283 | public long getCurrSpeed() { |
| 284 | return currSpeed; |
| 285 | } |
| 286 | |
| 287 | @Override |
| 288 | public OFPortDesc.Builder setCurrSpeed(long currSpeed) { |
| 289 | this.currSpeed = currSpeed; |
| 290 | this.currSpeedSet = true; |
| 291 | return this; |
| 292 | } |
| 293 | @Override |
| 294 | public long getMaxSpeed() { |
| 295 | return maxSpeed; |
| 296 | } |
| 297 | |
| 298 | @Override |
| 299 | public OFPortDesc.Builder setMaxSpeed(long maxSpeed) { |
| 300 | this.maxSpeed = maxSpeed; |
| 301 | this.maxSpeedSet = true; |
| 302 | return this; |
| 303 | } |
| 304 | @Override |
| 305 | public OFVersion getVersion() { |
| 306 | return OFVersion.OF_11; |
| 307 | } |
| 308 | |
| 309 | |
| 310 | |
| 311 | @Override |
| 312 | public OFPortDesc build() { |
| 313 | OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo; |
| 314 | if(portNo == null) |
| 315 | throw new NullPointerException("Property portNo must not be null"); |
| 316 | MacAddress hwAddr = this.hwAddrSet ? this.hwAddr : parentMessage.hwAddr; |
| 317 | if(hwAddr == null) |
| 318 | throw new NullPointerException("Property hwAddr must not be null"); |
| 319 | String name = this.nameSet ? this.name : parentMessage.name; |
| 320 | if(name == null) |
| 321 | throw new NullPointerException("Property name must not be null"); |
| 322 | Set<OFPortConfig> config = this.configSet ? this.config : parentMessage.config; |
| 323 | if(config == null) |
| 324 | throw new NullPointerException("Property config must not be null"); |
| 325 | Set<OFPortState> state = this.stateSet ? this.state : parentMessage.state; |
| 326 | if(state == null) |
| 327 | throw new NullPointerException("Property state must not be null"); |
| 328 | Set<OFPortFeatures> curr = this.currSet ? this.curr : parentMessage.curr; |
| 329 | if(curr == null) |
| 330 | throw new NullPointerException("Property curr must not be null"); |
| 331 | Set<OFPortFeatures> advertised = this.advertisedSet ? this.advertised : parentMessage.advertised; |
| 332 | if(advertised == null) |
| 333 | throw new NullPointerException("Property advertised must not be null"); |
| 334 | Set<OFPortFeatures> supported = this.supportedSet ? this.supported : parentMessage.supported; |
| 335 | if(supported == null) |
| 336 | throw new NullPointerException("Property supported must not be null"); |
| 337 | Set<OFPortFeatures> peer = this.peerSet ? this.peer : parentMessage.peer; |
| 338 | if(peer == null) |
| 339 | throw new NullPointerException("Property peer must not be null"); |
| 340 | long currSpeed = this.currSpeedSet ? this.currSpeed : parentMessage.currSpeed; |
| 341 | long maxSpeed = this.maxSpeedSet ? this.maxSpeed : parentMessage.maxSpeed; |
| 342 | |
| 343 | // |
| 344 | return new OFPortDescVer11( |
| 345 | portNo, |
| 346 | hwAddr, |
| 347 | name, |
| 348 | config, |
| 349 | state, |
| 350 | curr, |
| 351 | advertised, |
| 352 | supported, |
| 353 | peer, |
| 354 | currSpeed, |
| 355 | maxSpeed |
| 356 | ); |
| 357 | } |
| 358 | |
| 359 | } |
| 360 | |
| 361 | static class Builder implements OFPortDesc.Builder { |
| 362 | // OF message fields |
| 363 | private boolean portNoSet; |
| 364 | private OFPort portNo; |
| 365 | private boolean hwAddrSet; |
| 366 | private MacAddress hwAddr; |
| 367 | private boolean nameSet; |
| 368 | private String name; |
| 369 | private boolean configSet; |
| 370 | private Set<OFPortConfig> config; |
| 371 | private boolean stateSet; |
| 372 | private Set<OFPortState> state; |
| 373 | private boolean currSet; |
| 374 | private Set<OFPortFeatures> curr; |
| 375 | private boolean advertisedSet; |
| 376 | private Set<OFPortFeatures> advertised; |
| 377 | private boolean supportedSet; |
| 378 | private Set<OFPortFeatures> supported; |
| 379 | private boolean peerSet; |
| 380 | private Set<OFPortFeatures> peer; |
| 381 | private boolean currSpeedSet; |
| 382 | private long currSpeed; |
| 383 | private boolean maxSpeedSet; |
| 384 | private long maxSpeed; |
| 385 | |
| 386 | @Override |
| 387 | public OFPort getPortNo() { |
| 388 | return portNo; |
| 389 | } |
| 390 | |
| 391 | @Override |
| 392 | public OFPortDesc.Builder setPortNo(OFPort portNo) { |
| 393 | this.portNo = portNo; |
| 394 | this.portNoSet = true; |
| 395 | return this; |
| 396 | } |
| 397 | @Override |
| 398 | public MacAddress getHwAddr() { |
| 399 | return hwAddr; |
| 400 | } |
| 401 | |
| 402 | @Override |
| 403 | public OFPortDesc.Builder setHwAddr(MacAddress hwAddr) { |
| 404 | this.hwAddr = hwAddr; |
| 405 | this.hwAddrSet = true; |
| 406 | return this; |
| 407 | } |
| 408 | @Override |
| 409 | public String getName() { |
| 410 | return name; |
| 411 | } |
| 412 | |
| 413 | @Override |
| 414 | public OFPortDesc.Builder setName(String name) { |
| 415 | this.name = name; |
| 416 | this.nameSet = true; |
| 417 | return this; |
| 418 | } |
| 419 | @Override |
| 420 | public Set<OFPortConfig> getConfig() { |
| 421 | return config; |
| 422 | } |
| 423 | |
| 424 | @Override |
| 425 | public OFPortDesc.Builder setConfig(Set<OFPortConfig> config) { |
| 426 | this.config = config; |
| 427 | this.configSet = true; |
| 428 | return this; |
| 429 | } |
| 430 | @Override |
| 431 | public Set<OFPortState> getState() { |
| 432 | return state; |
| 433 | } |
| 434 | |
| 435 | @Override |
| 436 | public OFPortDesc.Builder setState(Set<OFPortState> state) { |
| 437 | this.state = state; |
| 438 | this.stateSet = true; |
| 439 | return this; |
| 440 | } |
| 441 | @Override |
| 442 | public Set<OFPortFeatures> getCurr() { |
| 443 | return curr; |
| 444 | } |
| 445 | |
| 446 | @Override |
| 447 | public OFPortDesc.Builder setCurr(Set<OFPortFeatures> curr) { |
| 448 | this.curr = curr; |
| 449 | this.currSet = true; |
| 450 | return this; |
| 451 | } |
| 452 | @Override |
| 453 | public Set<OFPortFeatures> getAdvertised() { |
| 454 | return advertised; |
| 455 | } |
| 456 | |
| 457 | @Override |
| 458 | public OFPortDesc.Builder setAdvertised(Set<OFPortFeatures> advertised) { |
| 459 | this.advertised = advertised; |
| 460 | this.advertisedSet = true; |
| 461 | return this; |
| 462 | } |
| 463 | @Override |
| 464 | public Set<OFPortFeatures> getSupported() { |
| 465 | return supported; |
| 466 | } |
| 467 | |
| 468 | @Override |
| 469 | public OFPortDesc.Builder setSupported(Set<OFPortFeatures> supported) { |
| 470 | this.supported = supported; |
| 471 | this.supportedSet = true; |
| 472 | return this; |
| 473 | } |
| 474 | @Override |
| 475 | public Set<OFPortFeatures> getPeer() { |
| 476 | return peer; |
| 477 | } |
| 478 | |
| 479 | @Override |
| 480 | public OFPortDesc.Builder setPeer(Set<OFPortFeatures> peer) { |
| 481 | this.peer = peer; |
| 482 | this.peerSet = true; |
| 483 | return this; |
| 484 | } |
| 485 | @Override |
| 486 | public long getCurrSpeed() { |
| 487 | return currSpeed; |
| 488 | } |
| 489 | |
| 490 | @Override |
| 491 | public OFPortDesc.Builder setCurrSpeed(long currSpeed) { |
| 492 | this.currSpeed = currSpeed; |
| 493 | this.currSpeedSet = true; |
| 494 | return this; |
| 495 | } |
| 496 | @Override |
| 497 | public long getMaxSpeed() { |
| 498 | return maxSpeed; |
| 499 | } |
| 500 | |
| 501 | @Override |
| 502 | public OFPortDesc.Builder setMaxSpeed(long maxSpeed) { |
| 503 | this.maxSpeed = maxSpeed; |
| 504 | this.maxSpeedSet = true; |
| 505 | return this; |
| 506 | } |
| 507 | @Override |
| 508 | public OFVersion getVersion() { |
| 509 | return OFVersion.OF_11; |
| 510 | } |
| 511 | |
| 512 | // |
| 513 | @Override |
| 514 | public OFPortDesc build() { |
| 515 | OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO; |
| 516 | if(portNo == null) |
| 517 | throw new NullPointerException("Property portNo must not be null"); |
| 518 | MacAddress hwAddr = this.hwAddrSet ? this.hwAddr : DEFAULT_HW_ADDR; |
| 519 | if(hwAddr == null) |
| 520 | throw new NullPointerException("Property hwAddr must not be null"); |
| 521 | String name = this.nameSet ? this.name : DEFAULT_NAME; |
| 522 | if(name == null) |
| 523 | throw new NullPointerException("Property name must not be null"); |
| 524 | Set<OFPortConfig> config = this.configSet ? this.config : DEFAULT_CONFIG; |
| 525 | if(config == null) |
| 526 | throw new NullPointerException("Property config must not be null"); |
| 527 | Set<OFPortState> state = this.stateSet ? this.state : DEFAULT_STATE; |
| 528 | if(state == null) |
| 529 | throw new NullPointerException("Property state must not be null"); |
| 530 | Set<OFPortFeatures> curr = this.currSet ? this.curr : DEFAULT_CURR; |
| 531 | if(curr == null) |
| 532 | throw new NullPointerException("Property curr must not be null"); |
| 533 | Set<OFPortFeatures> advertised = this.advertisedSet ? this.advertised : DEFAULT_ADVERTISED; |
| 534 | if(advertised == null) |
| 535 | throw new NullPointerException("Property advertised must not be null"); |
| 536 | Set<OFPortFeatures> supported = this.supportedSet ? this.supported : DEFAULT_SUPPORTED; |
| 537 | if(supported == null) |
| 538 | throw new NullPointerException("Property supported must not be null"); |
| 539 | Set<OFPortFeatures> peer = this.peerSet ? this.peer : DEFAULT_PEER; |
| 540 | if(peer == null) |
| 541 | throw new NullPointerException("Property peer must not be null"); |
| 542 | long currSpeed = this.currSpeedSet ? this.currSpeed : DEFAULT_CURR_SPEED; |
| 543 | long maxSpeed = this.maxSpeedSet ? this.maxSpeed : DEFAULT_MAX_SPEED; |
| 544 | |
| 545 | |
| 546 | return new OFPortDescVer11( |
| 547 | portNo, |
| 548 | hwAddr, |
| 549 | name, |
| 550 | config, |
| 551 | state, |
| 552 | curr, |
| 553 | advertised, |
| 554 | supported, |
| 555 | peer, |
| 556 | currSpeed, |
| 557 | maxSpeed |
| 558 | ); |
| 559 | } |
| 560 | |
| 561 | } |
| 562 | |
| 563 | |
| 564 | final static Reader READER = new Reader(); |
| 565 | static class Reader implements OFMessageReader<OFPortDesc> { |
| 566 | @Override |
| 567 | public OFPortDesc readFrom(ChannelBuffer bb) throws OFParseError { |
| 568 | OFPort portNo = OFPort.read4Bytes(bb); |
| 569 | // pad: 4 bytes |
| 570 | bb.skipBytes(4); |
| 571 | MacAddress hwAddr = MacAddress.read6Bytes(bb); |
| 572 | // pad: 2 bytes |
| 573 | bb.skipBytes(2); |
| 574 | String name = ChannelUtils.readFixedLengthString(bb, 16); |
| 575 | Set<OFPortConfig> config = OFPortConfigSerializerVer11.readFrom(bb); |
| 576 | Set<OFPortState> state = OFPortStateSerializerVer11.readFrom(bb); |
| 577 | Set<OFPortFeatures> curr = OFPortFeaturesSerializerVer11.readFrom(bb); |
| 578 | Set<OFPortFeatures> advertised = OFPortFeaturesSerializerVer11.readFrom(bb); |
| 579 | Set<OFPortFeatures> supported = OFPortFeaturesSerializerVer11.readFrom(bb); |
| 580 | Set<OFPortFeatures> peer = OFPortFeaturesSerializerVer11.readFrom(bb); |
| 581 | long currSpeed = U32.f(bb.readInt()); |
| 582 | long maxSpeed = U32.f(bb.readInt()); |
| 583 | |
| 584 | OFPortDescVer11 portDescVer11 = new OFPortDescVer11( |
| 585 | portNo, |
| 586 | hwAddr, |
| 587 | name, |
| 588 | config, |
| 589 | state, |
| 590 | curr, |
| 591 | advertised, |
| 592 | supported, |
| 593 | peer, |
| 594 | currSpeed, |
| 595 | maxSpeed |
| 596 | ); |
| 597 | if(logger.isTraceEnabled()) |
| 598 | logger.trace("readFrom - read={}", portDescVer11); |
| 599 | return portDescVer11; |
| 600 | } |
| 601 | } |
| 602 | |
| 603 | public void putTo(PrimitiveSink sink) { |
| 604 | FUNNEL.funnel(this, sink); |
| 605 | } |
| 606 | |
| 607 | final static OFPortDescVer11Funnel FUNNEL = new OFPortDescVer11Funnel(); |
| 608 | static class OFPortDescVer11Funnel implements Funnel<OFPortDescVer11> { |
| 609 | private static final long serialVersionUID = 1L; |
| 610 | @Override |
| 611 | public void funnel(OFPortDescVer11 message, PrimitiveSink sink) { |
| 612 | message.portNo.putTo(sink); |
| 613 | // skip pad (4 bytes) |
| 614 | message.hwAddr.putTo(sink); |
| 615 | // skip pad (2 bytes) |
| 616 | sink.putUnencodedChars(message.name); |
| 617 | OFPortConfigSerializerVer11.putTo(message.config, sink); |
| 618 | OFPortStateSerializerVer11.putTo(message.state, sink); |
| 619 | OFPortFeaturesSerializerVer11.putTo(message.curr, sink); |
| 620 | OFPortFeaturesSerializerVer11.putTo(message.advertised, sink); |
| 621 | OFPortFeaturesSerializerVer11.putTo(message.supported, sink); |
| 622 | OFPortFeaturesSerializerVer11.putTo(message.peer, sink); |
| 623 | sink.putLong(message.currSpeed); |
| 624 | sink.putLong(message.maxSpeed); |
| 625 | } |
| 626 | } |
| 627 | |
| 628 | |
| 629 | public void writeTo(ChannelBuffer bb) { |
| 630 | WRITER.write(bb, this); |
| 631 | } |
| 632 | |
| 633 | final static Writer WRITER = new Writer(); |
| 634 | static class Writer implements OFMessageWriter<OFPortDescVer11> { |
| 635 | @Override |
| 636 | public void write(ChannelBuffer bb, OFPortDescVer11 message) { |
| 637 | message.portNo.write4Bytes(bb); |
| 638 | // pad: 4 bytes |
| 639 | bb.writeZero(4); |
| 640 | message.hwAddr.write6Bytes(bb); |
| 641 | // pad: 2 bytes |
| 642 | bb.writeZero(2); |
| 643 | ChannelUtils.writeFixedLengthString(bb, message.name, 16); |
| 644 | OFPortConfigSerializerVer11.writeTo(bb, message.config); |
| 645 | OFPortStateSerializerVer11.writeTo(bb, message.state); |
| 646 | OFPortFeaturesSerializerVer11.writeTo(bb, message.curr); |
| 647 | OFPortFeaturesSerializerVer11.writeTo(bb, message.advertised); |
| 648 | OFPortFeaturesSerializerVer11.writeTo(bb, message.supported); |
| 649 | OFPortFeaturesSerializerVer11.writeTo(bb, message.peer); |
| 650 | bb.writeInt(U32.t(message.currSpeed)); |
| 651 | bb.writeInt(U32.t(message.maxSpeed)); |
| 652 | |
| 653 | |
| 654 | } |
| 655 | } |
| 656 | |
| 657 | @Override |
| 658 | public String toString() { |
| 659 | StringBuilder b = new StringBuilder("OFPortDescVer11("); |
| 660 | b.append("portNo=").append(portNo); |
| 661 | b.append(", "); |
| 662 | b.append("hwAddr=").append(hwAddr); |
| 663 | b.append(", "); |
| 664 | b.append("name=").append(name); |
| 665 | b.append(", "); |
| 666 | b.append("config=").append(config); |
| 667 | b.append(", "); |
| 668 | b.append("state=").append(state); |
| 669 | b.append(", "); |
| 670 | b.append("curr=").append(curr); |
| 671 | b.append(", "); |
| 672 | b.append("advertised=").append(advertised); |
| 673 | b.append(", "); |
| 674 | b.append("supported=").append(supported); |
| 675 | b.append(", "); |
| 676 | b.append("peer=").append(peer); |
| 677 | b.append(", "); |
| 678 | b.append("currSpeed=").append(currSpeed); |
| 679 | b.append(", "); |
| 680 | b.append("maxSpeed=").append(maxSpeed); |
| 681 | b.append(")"); |
| 682 | return b.toString(); |
| 683 | } |
| 684 | |
| 685 | @Override |
| 686 | public boolean equals(Object obj) { |
| 687 | if (this == obj) |
| 688 | return true; |
| 689 | if (obj == null) |
| 690 | return false; |
| 691 | if (getClass() != obj.getClass()) |
| 692 | return false; |
| 693 | OFPortDescVer11 other = (OFPortDescVer11) obj; |
| 694 | |
| 695 | if (portNo == null) { |
| 696 | if (other.portNo != null) |
| 697 | return false; |
| 698 | } else if (!portNo.equals(other.portNo)) |
| 699 | return false; |
| 700 | if (hwAddr == null) { |
| 701 | if (other.hwAddr != null) |
| 702 | return false; |
| 703 | } else if (!hwAddr.equals(other.hwAddr)) |
| 704 | return false; |
| 705 | if (name == null) { |
| 706 | if (other.name != null) |
| 707 | return false; |
| 708 | } else if (!name.equals(other.name)) |
| 709 | return false; |
| 710 | if (config == null) { |
| 711 | if (other.config != null) |
| 712 | return false; |
| 713 | } else if (!config.equals(other.config)) |
| 714 | return false; |
| 715 | if (state == null) { |
| 716 | if (other.state != null) |
| 717 | return false; |
| 718 | } else if (!state.equals(other.state)) |
| 719 | return false; |
| 720 | if (curr == null) { |
| 721 | if (other.curr != null) |
| 722 | return false; |
| 723 | } else if (!curr.equals(other.curr)) |
| 724 | return false; |
| 725 | if (advertised == null) { |
| 726 | if (other.advertised != null) |
| 727 | return false; |
| 728 | } else if (!advertised.equals(other.advertised)) |
| 729 | return false; |
| 730 | if (supported == null) { |
| 731 | if (other.supported != null) |
| 732 | return false; |
| 733 | } else if (!supported.equals(other.supported)) |
| 734 | return false; |
| 735 | if (peer == null) { |
| 736 | if (other.peer != null) |
| 737 | return false; |
| 738 | } else if (!peer.equals(other.peer)) |
| 739 | return false; |
| 740 | if( currSpeed != other.currSpeed) |
| 741 | return false; |
| 742 | if( maxSpeed != other.maxSpeed) |
| 743 | return false; |
| 744 | return true; |
| 745 | } |
| 746 | |
| 747 | @Override |
| 748 | public int hashCode() { |
| 749 | final int prime = 31; |
| 750 | int result = 1; |
| 751 | |
| 752 | result = prime * result + ((portNo == null) ? 0 : portNo.hashCode()); |
| 753 | result = prime * result + ((hwAddr == null) ? 0 : hwAddr.hashCode()); |
| 754 | result = prime * result + ((name == null) ? 0 : name.hashCode()); |
| 755 | result = prime * result + ((config == null) ? 0 : config.hashCode()); |
| 756 | result = prime * result + ((state == null) ? 0 : state.hashCode()); |
| 757 | result = prime * result + ((curr == null) ? 0 : curr.hashCode()); |
| 758 | result = prime * result + ((advertised == null) ? 0 : advertised.hashCode()); |
| 759 | result = prime * result + ((supported == null) ? 0 : supported.hashCode()); |
| 760 | result = prime * result + ((peer == null) ? 0 : peer.hashCode()); |
| 761 | result = prime * (int) (currSpeed ^ (currSpeed >>> 32)); |
| 762 | result = prime * (int) (maxSpeed ^ (maxSpeed >>> 32)); |
| 763 | return result; |
| 764 | } |
| 765 | |
| 766 | } |