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 OFPacketInVer10 implements OFPacketIn { |
| 35 | private static final Logger logger = LoggerFactory.getLogger(OFPacketInVer10.class); |
| 36 | // version: 1.0 |
| 37 | final static byte WIRE_VERSION = 1; |
| 38 | final static int MINIMUM_LENGTH = 18; |
| 39 | |
| 40 | private final static long DEFAULT_XID = 0x0L; |
| 41 | private final static OFBufferId DEFAULT_BUFFER_ID = OFBufferId.NO_BUFFER; |
| 42 | private final static int DEFAULT_TOTAL_LEN = 0x0; |
| 43 | private final static OFPort DEFAULT_IN_PORT = OFPort.ANY; |
| 44 | private final static byte[] DEFAULT_DATA = new byte[0]; |
| 45 | |
| 46 | // OF message fields |
| 47 | private final long xid; |
| 48 | private final OFBufferId bufferId; |
| 49 | private final int totalLen; |
| 50 | private final OFPort inPort; |
| 51 | private final OFPacketInReason reason; |
| 52 | private final byte[] data; |
| 53 | // |
| 54 | |
| 55 | // package private constructor - used by readers, builders, and factory |
| 56 | OFPacketInVer10(long xid, OFBufferId bufferId, int totalLen, OFPort inPort, OFPacketInReason reason, byte[] data) { |
| 57 | this.xid = xid; |
| 58 | this.bufferId = bufferId; |
| 59 | this.totalLen = totalLen; |
| 60 | this.inPort = inPort; |
| 61 | this.reason = reason; |
| 62 | this.data = data; |
| 63 | } |
| 64 | |
| 65 | // Accessors for OF message fields |
| 66 | @Override |
| 67 | public OFVersion getVersion() { |
| 68 | return OFVersion.OF_10; |
| 69 | } |
| 70 | |
| 71 | @Override |
| 72 | public OFType getType() { |
| 73 | return OFType.PACKET_IN; |
| 74 | } |
| 75 | |
| 76 | @Override |
| 77 | public long getXid() { |
| 78 | return xid; |
| 79 | } |
| 80 | |
| 81 | @Override |
| 82 | public OFBufferId getBufferId() { |
| 83 | return bufferId; |
| 84 | } |
| 85 | |
| 86 | @Override |
| 87 | public int getTotalLen() { |
| 88 | return totalLen; |
| 89 | } |
| 90 | |
| 91 | @Override |
| 92 | public OFPacketInReason getReason() { |
| 93 | return reason; |
| 94 | } |
| 95 | |
| 96 | @Override |
| 97 | public TableId getTableId()throws UnsupportedOperationException { |
| 98 | throw new UnsupportedOperationException("Property tableId not supported in version 1.0"); |
| 99 | } |
| 100 | |
| 101 | @Override |
| 102 | public Match getMatch()throws UnsupportedOperationException { |
| 103 | throw new UnsupportedOperationException("Property match not supported in version 1.0"); |
| 104 | } |
| 105 | |
| 106 | @Override |
| 107 | public byte[] getData() { |
| 108 | return data; |
| 109 | } |
| 110 | |
| 111 | @Override |
| 112 | public OFPort getInPort() { |
| 113 | return inPort; |
| 114 | } |
| 115 | |
| 116 | @Override |
| 117 | public OFPort getInPhyPort()throws UnsupportedOperationException { |
| 118 | throw new UnsupportedOperationException("Property inPhyPort not supported in version 1.0"); |
| 119 | } |
| 120 | |
| 121 | @Override |
| 122 | public U64 getCookie()throws UnsupportedOperationException { |
| 123 | throw new UnsupportedOperationException("Property cookie not supported in version 1.0"); |
| 124 | } |
| 125 | |
| 126 | |
| 127 | |
| 128 | public OFPacketIn.Builder createBuilder() { |
| 129 | return new BuilderWithParent(this); |
| 130 | } |
| 131 | |
| 132 | static class BuilderWithParent implements OFPacketIn.Builder { |
| 133 | final OFPacketInVer10 parentMessage; |
| 134 | |
| 135 | // OF message fields |
| 136 | private boolean xidSet; |
| 137 | private long xid; |
| 138 | private boolean bufferIdSet; |
| 139 | private OFBufferId bufferId; |
| 140 | private boolean totalLenSet; |
| 141 | private int totalLen; |
| 142 | private boolean inPortSet; |
| 143 | private OFPort inPort; |
| 144 | private boolean reasonSet; |
| 145 | private OFPacketInReason reason; |
| 146 | private boolean dataSet; |
| 147 | private byte[] data; |
| 148 | |
| 149 | BuilderWithParent(OFPacketInVer10 parentMessage) { |
| 150 | this.parentMessage = parentMessage; |
| 151 | } |
| 152 | |
| 153 | @Override |
| 154 | public OFVersion getVersion() { |
| 155 | return OFVersion.OF_10; |
| 156 | } |
| 157 | |
| 158 | @Override |
| 159 | public OFType getType() { |
| 160 | return OFType.PACKET_IN; |
| 161 | } |
| 162 | |
| 163 | @Override |
| 164 | public long getXid() { |
| 165 | return xid; |
| 166 | } |
| 167 | |
| 168 | @Override |
| 169 | public OFPacketIn.Builder setXid(long xid) { |
| 170 | this.xid = xid; |
| 171 | this.xidSet = true; |
| 172 | return this; |
| 173 | } |
| 174 | @Override |
| 175 | public OFBufferId getBufferId() { |
| 176 | return bufferId; |
| 177 | } |
| 178 | |
| 179 | @Override |
| 180 | public OFPacketIn.Builder setBufferId(OFBufferId bufferId) { |
| 181 | this.bufferId = bufferId; |
| 182 | this.bufferIdSet = true; |
| 183 | return this; |
| 184 | } |
| 185 | @Override |
| 186 | public int getTotalLen() { |
| 187 | return totalLen; |
| 188 | } |
| 189 | |
| 190 | @Override |
| 191 | public OFPacketIn.Builder setTotalLen(int totalLen) { |
| 192 | this.totalLen = totalLen; |
| 193 | this.totalLenSet = true; |
| 194 | return this; |
| 195 | } |
| 196 | @Override |
| 197 | public OFPacketInReason getReason() { |
| 198 | return reason; |
| 199 | } |
| 200 | |
| 201 | @Override |
| 202 | public OFPacketIn.Builder setReason(OFPacketInReason reason) { |
| 203 | this.reason = reason; |
| 204 | this.reasonSet = true; |
| 205 | return this; |
| 206 | } |
| 207 | @Override |
| 208 | public TableId getTableId()throws UnsupportedOperationException { |
| 209 | throw new UnsupportedOperationException("Property tableId not supported in version 1.0"); |
| 210 | } |
| 211 | |
| 212 | @Override |
| 213 | public OFPacketIn.Builder setTableId(TableId tableId) throws UnsupportedOperationException { |
| 214 | throw new UnsupportedOperationException("Property tableId not supported in version 1.0"); |
| 215 | } |
| 216 | @Override |
| 217 | public Match getMatch()throws UnsupportedOperationException { |
| 218 | throw new UnsupportedOperationException("Property match not supported in version 1.0"); |
| 219 | } |
| 220 | |
| 221 | @Override |
| 222 | public OFPacketIn.Builder setMatch(Match match) throws UnsupportedOperationException { |
| 223 | throw new UnsupportedOperationException("Property match not supported in version 1.0"); |
| 224 | } |
| 225 | @Override |
| 226 | public byte[] getData() { |
| 227 | return data; |
| 228 | } |
| 229 | |
| 230 | @Override |
| 231 | public OFPacketIn.Builder setData(byte[] data) { |
| 232 | this.data = data; |
| 233 | this.dataSet = true; |
| 234 | return this; |
| 235 | } |
| 236 | @Override |
| 237 | public OFPort getInPort() { |
| 238 | return inPort; |
| 239 | } |
| 240 | |
| 241 | @Override |
| 242 | public OFPacketIn.Builder setInPort(OFPort inPort) { |
| 243 | this.inPort = inPort; |
| 244 | this.inPortSet = true; |
| 245 | return this; |
| 246 | } |
| 247 | @Override |
| 248 | public OFPort getInPhyPort()throws UnsupportedOperationException { |
| 249 | throw new UnsupportedOperationException("Property inPhyPort not supported in version 1.0"); |
| 250 | } |
| 251 | |
| 252 | @Override |
| 253 | public OFPacketIn.Builder setInPhyPort(OFPort inPhyPort) throws UnsupportedOperationException { |
| 254 | throw new UnsupportedOperationException("Property inPhyPort not supported in version 1.0"); |
| 255 | } |
| 256 | @Override |
| 257 | public U64 getCookie()throws UnsupportedOperationException { |
| 258 | throw new UnsupportedOperationException("Property cookie not supported in version 1.0"); |
| 259 | } |
| 260 | |
| 261 | @Override |
| 262 | public OFPacketIn.Builder setCookie(U64 cookie) throws UnsupportedOperationException { |
| 263 | throw new UnsupportedOperationException("Property cookie not supported in version 1.0"); |
| 264 | } |
| 265 | |
| 266 | |
| 267 | @Override |
| 268 | public OFPacketIn build() { |
| 269 | long xid = this.xidSet ? this.xid : parentMessage.xid; |
| 270 | OFBufferId bufferId = this.bufferIdSet ? this.bufferId : parentMessage.bufferId; |
| 271 | if(bufferId == null) |
| 272 | throw new NullPointerException("Property bufferId must not be null"); |
| 273 | int totalLen = this.totalLenSet ? this.totalLen : parentMessage.totalLen; |
| 274 | OFPort inPort = this.inPortSet ? this.inPort : parentMessage.inPort; |
| 275 | if(inPort == null) |
| 276 | throw new NullPointerException("Property inPort must not be null"); |
| 277 | OFPacketInReason reason = this.reasonSet ? this.reason : parentMessage.reason; |
| 278 | if(reason == null) |
| 279 | throw new NullPointerException("Property reason must not be null"); |
| 280 | byte[] data = this.dataSet ? this.data : parentMessage.data; |
| 281 | if(data == null) |
| 282 | throw new NullPointerException("Property data must not be null"); |
| 283 | |
| 284 | // |
| 285 | return new OFPacketInVer10( |
| 286 | xid, |
| 287 | bufferId, |
| 288 | totalLen, |
| 289 | inPort, |
| 290 | reason, |
| 291 | data |
| 292 | ); |
| 293 | } |
| 294 | |
| 295 | } |
| 296 | |
| 297 | static class Builder implements OFPacketIn.Builder { |
| 298 | // OF message fields |
| 299 | private boolean xidSet; |
| 300 | private long xid; |
| 301 | private boolean bufferIdSet; |
| 302 | private OFBufferId bufferId; |
| 303 | private boolean totalLenSet; |
| 304 | private int totalLen; |
| 305 | private boolean inPortSet; |
| 306 | private OFPort inPort; |
| 307 | private boolean reasonSet; |
| 308 | private OFPacketInReason reason; |
| 309 | private boolean dataSet; |
| 310 | private byte[] data; |
| 311 | |
| 312 | @Override |
| 313 | public OFVersion getVersion() { |
| 314 | return OFVersion.OF_10; |
| 315 | } |
| 316 | |
| 317 | @Override |
| 318 | public OFType getType() { |
| 319 | return OFType.PACKET_IN; |
| 320 | } |
| 321 | |
| 322 | @Override |
| 323 | public long getXid() { |
| 324 | return xid; |
| 325 | } |
| 326 | |
| 327 | @Override |
| 328 | public OFPacketIn.Builder setXid(long xid) { |
| 329 | this.xid = xid; |
| 330 | this.xidSet = true; |
| 331 | return this; |
| 332 | } |
| 333 | @Override |
| 334 | public OFBufferId getBufferId() { |
| 335 | return bufferId; |
| 336 | } |
| 337 | |
| 338 | @Override |
| 339 | public OFPacketIn.Builder setBufferId(OFBufferId bufferId) { |
| 340 | this.bufferId = bufferId; |
| 341 | this.bufferIdSet = true; |
| 342 | return this; |
| 343 | } |
| 344 | @Override |
| 345 | public int getTotalLen() { |
| 346 | return totalLen; |
| 347 | } |
| 348 | |
| 349 | @Override |
| 350 | public OFPacketIn.Builder setTotalLen(int totalLen) { |
| 351 | this.totalLen = totalLen; |
| 352 | this.totalLenSet = true; |
| 353 | return this; |
| 354 | } |
| 355 | @Override |
| 356 | public OFPacketInReason getReason() { |
| 357 | return reason; |
| 358 | } |
| 359 | |
| 360 | @Override |
| 361 | public OFPacketIn.Builder setReason(OFPacketInReason reason) { |
| 362 | this.reason = reason; |
| 363 | this.reasonSet = true; |
| 364 | return this; |
| 365 | } |
| 366 | @Override |
| 367 | public TableId getTableId()throws UnsupportedOperationException { |
| 368 | throw new UnsupportedOperationException("Property tableId not supported in version 1.0"); |
| 369 | } |
| 370 | |
| 371 | @Override |
| 372 | public OFPacketIn.Builder setTableId(TableId tableId) throws UnsupportedOperationException { |
| 373 | throw new UnsupportedOperationException("Property tableId not supported in version 1.0"); |
| 374 | } |
| 375 | @Override |
| 376 | public Match getMatch()throws UnsupportedOperationException { |
| 377 | throw new UnsupportedOperationException("Property match not supported in version 1.0"); |
| 378 | } |
| 379 | |
| 380 | @Override |
| 381 | public OFPacketIn.Builder setMatch(Match match) throws UnsupportedOperationException { |
| 382 | throw new UnsupportedOperationException("Property match not supported in version 1.0"); |
| 383 | } |
| 384 | @Override |
| 385 | public byte[] getData() { |
| 386 | return data; |
| 387 | } |
| 388 | |
| 389 | @Override |
| 390 | public OFPacketIn.Builder setData(byte[] data) { |
| 391 | this.data = data; |
| 392 | this.dataSet = true; |
| 393 | return this; |
| 394 | } |
| 395 | @Override |
| 396 | public OFPort getInPort() { |
| 397 | return inPort; |
| 398 | } |
| 399 | |
| 400 | @Override |
| 401 | public OFPacketIn.Builder setInPort(OFPort inPort) { |
| 402 | this.inPort = inPort; |
| 403 | this.inPortSet = true; |
| 404 | return this; |
| 405 | } |
| 406 | @Override |
| 407 | public OFPort getInPhyPort()throws UnsupportedOperationException { |
| 408 | throw new UnsupportedOperationException("Property inPhyPort not supported in version 1.0"); |
| 409 | } |
| 410 | |
| 411 | @Override |
| 412 | public OFPacketIn.Builder setInPhyPort(OFPort inPhyPort) throws UnsupportedOperationException { |
| 413 | throw new UnsupportedOperationException("Property inPhyPort not supported in version 1.0"); |
| 414 | } |
| 415 | @Override |
| 416 | public U64 getCookie()throws UnsupportedOperationException { |
| 417 | throw new UnsupportedOperationException("Property cookie not supported in version 1.0"); |
| 418 | } |
| 419 | |
| 420 | @Override |
| 421 | public OFPacketIn.Builder setCookie(U64 cookie) throws UnsupportedOperationException { |
| 422 | throw new UnsupportedOperationException("Property cookie not supported in version 1.0"); |
| 423 | } |
| 424 | // |
| 425 | @Override |
| 426 | public OFPacketIn build() { |
| 427 | long xid = this.xidSet ? this.xid : DEFAULT_XID; |
| 428 | OFBufferId bufferId = this.bufferIdSet ? this.bufferId : DEFAULT_BUFFER_ID; |
| 429 | if(bufferId == null) |
| 430 | throw new NullPointerException("Property bufferId must not be null"); |
| 431 | int totalLen = this.totalLenSet ? this.totalLen : DEFAULT_TOTAL_LEN; |
| 432 | OFPort inPort = this.inPortSet ? this.inPort : DEFAULT_IN_PORT; |
| 433 | if(inPort == null) |
| 434 | throw new NullPointerException("Property inPort must not be null"); |
| 435 | if(!this.reasonSet) |
| 436 | throw new IllegalStateException("Property reason doesn't have default value -- must be set"); |
| 437 | if(reason == null) |
| 438 | throw new NullPointerException("Property reason must not be null"); |
| 439 | byte[] data = this.dataSet ? this.data : DEFAULT_DATA; |
| 440 | if(data == null) |
| 441 | throw new NullPointerException("Property data must not be null"); |
| 442 | |
| 443 | |
| 444 | return new OFPacketInVer10( |
| 445 | xid, |
| 446 | bufferId, |
| 447 | totalLen, |
| 448 | inPort, |
| 449 | reason, |
| 450 | data |
| 451 | ); |
| 452 | } |
| 453 | |
| 454 | } |
| 455 | |
| 456 | |
| 457 | final static Reader READER = new Reader(); |
| 458 | static class Reader implements OFMessageReader<OFPacketIn> { |
| 459 | @Override |
| 460 | public OFPacketIn readFrom(ChannelBuffer bb) throws OFParseError { |
| 461 | int start = bb.readerIndex(); |
| 462 | // fixed value property version == 1 |
| 463 | byte version = bb.readByte(); |
| 464 | if(version != (byte) 0x1) |
| 465 | throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version); |
| 466 | // fixed value property type == 10 |
| 467 | byte type = bb.readByte(); |
| 468 | if(type != (byte) 0xa) |
| 469 | throw new OFParseError("Wrong type: Expected=OFType.PACKET_IN(10), got="+type); |
| 470 | int length = U16.f(bb.readShort()); |
| 471 | if(length < MINIMUM_LENGTH) |
| 472 | throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length); |
| 473 | if(bb.readableBytes() + (bb.readerIndex() - start) < length) { |
| 474 | // Buffer does not have all data yet |
| 475 | bb.readerIndex(start); |
| 476 | return null; |
| 477 | } |
| 478 | if(logger.isTraceEnabled()) |
| 479 | logger.trace("readFrom - length={}", length); |
| 480 | long xid = U32.f(bb.readInt()); |
| 481 | OFBufferId bufferId = OFBufferId.of(bb.readInt()); |
| 482 | int totalLen = U16.f(bb.readShort()); |
| 483 | OFPort inPort = OFPort.read2Bytes(bb); |
| 484 | OFPacketInReason reason = OFPacketInReasonSerializerVer10.readFrom(bb); |
| 485 | // pad: 1 bytes |
| 486 | bb.skipBytes(1); |
| 487 | byte[] data = ChannelUtils.readBytes(bb, length - (bb.readerIndex() - start)); |
| 488 | |
| 489 | OFPacketInVer10 packetInVer10 = new OFPacketInVer10( |
| 490 | xid, |
| 491 | bufferId, |
| 492 | totalLen, |
| 493 | inPort, |
| 494 | reason, |
| 495 | data |
| 496 | ); |
| 497 | if(logger.isTraceEnabled()) |
| 498 | logger.trace("readFrom - read={}", packetInVer10); |
| 499 | return packetInVer10; |
| 500 | } |
| 501 | } |
| 502 | |
| 503 | public void putTo(PrimitiveSink sink) { |
| 504 | FUNNEL.funnel(this, sink); |
| 505 | } |
| 506 | |
| 507 | final static OFPacketInVer10Funnel FUNNEL = new OFPacketInVer10Funnel(); |
| 508 | static class OFPacketInVer10Funnel implements Funnel<OFPacketInVer10> { |
| 509 | private static final long serialVersionUID = 1L; |
| 510 | @Override |
| 511 | public void funnel(OFPacketInVer10 message, PrimitiveSink sink) { |
| 512 | // fixed value property version = 1 |
| 513 | sink.putByte((byte) 0x1); |
| 514 | // fixed value property type = 10 |
| 515 | sink.putByte((byte) 0xa); |
| 516 | // FIXME: skip funnel of length |
| 517 | sink.putLong(message.xid); |
| 518 | message.bufferId.putTo(sink); |
| 519 | sink.putInt(message.totalLen); |
| 520 | message.inPort.putTo(sink); |
| 521 | OFPacketInReasonSerializerVer10.putTo(message.reason, sink); |
| 522 | // skip pad (1 bytes) |
| 523 | sink.putBytes(message.data); |
| 524 | } |
| 525 | } |
| 526 | |
| 527 | |
| 528 | public void writeTo(ChannelBuffer bb) { |
| 529 | WRITER.write(bb, this); |
| 530 | } |
| 531 | |
| 532 | final static Writer WRITER = new Writer(); |
| 533 | static class Writer implements OFMessageWriter<OFPacketInVer10> { |
| 534 | @Override |
| 535 | public void write(ChannelBuffer bb, OFPacketInVer10 message) { |
| 536 | int startIndex = bb.writerIndex(); |
| 537 | // fixed value property version = 1 |
| 538 | bb.writeByte((byte) 0x1); |
| 539 | // fixed value property type = 10 |
| 540 | bb.writeByte((byte) 0xa); |
| 541 | // length is length of variable message, will be updated at the end |
| 542 | int lengthIndex = bb.writerIndex(); |
| 543 | bb.writeShort(U16.t(0)); |
| 544 | |
| 545 | bb.writeInt(U32.t(message.xid)); |
| 546 | bb.writeInt(message.bufferId.getInt()); |
| 547 | bb.writeShort(U16.t(message.totalLen)); |
| 548 | message.inPort.write2Bytes(bb); |
| 549 | OFPacketInReasonSerializerVer10.writeTo(bb, message.reason); |
| 550 | // pad: 1 bytes |
| 551 | bb.writeZero(1); |
| 552 | bb.writeBytes(message.data); |
| 553 | |
| 554 | // update length field |
| 555 | int length = bb.writerIndex() - startIndex; |
| 556 | bb.setShort(lengthIndex, length); |
| 557 | |
| 558 | } |
| 559 | } |
| 560 | |
| 561 | @Override |
| 562 | public String toString() { |
| 563 | StringBuilder b = new StringBuilder("OFPacketInVer10("); |
| 564 | b.append("xid=").append(xid); |
| 565 | b.append(", "); |
| 566 | b.append("bufferId=").append(bufferId); |
| 567 | b.append(", "); |
| 568 | b.append("totalLen=").append(totalLen); |
| 569 | b.append(", "); |
| 570 | b.append("inPort=").append(inPort); |
| 571 | b.append(", "); |
| 572 | b.append("reason=").append(reason); |
| 573 | b.append(", "); |
| 574 | b.append("data=").append(Arrays.toString(data)); |
| 575 | b.append(")"); |
| 576 | return b.toString(); |
| 577 | } |
| 578 | |
| 579 | @Override |
| 580 | public boolean equals(Object obj) { |
| 581 | if (this == obj) |
| 582 | return true; |
| 583 | if (obj == null) |
| 584 | return false; |
| 585 | if (getClass() != obj.getClass()) |
| 586 | return false; |
| 587 | OFPacketInVer10 other = (OFPacketInVer10) obj; |
| 588 | |
| 589 | if( xid != other.xid) |
| 590 | return false; |
| 591 | if (bufferId == null) { |
| 592 | if (other.bufferId != null) |
| 593 | return false; |
| 594 | } else if (!bufferId.equals(other.bufferId)) |
| 595 | return false; |
| 596 | if( totalLen != other.totalLen) |
| 597 | return false; |
| 598 | if (inPort == null) { |
| 599 | if (other.inPort != null) |
| 600 | return false; |
| 601 | } else if (!inPort.equals(other.inPort)) |
| 602 | return false; |
| 603 | if (reason == null) { |
| 604 | if (other.reason != null) |
| 605 | return false; |
| 606 | } else if (!reason.equals(other.reason)) |
| 607 | return false; |
| 608 | if (!Arrays.equals(data, other.data)) |
| 609 | return false; |
| 610 | return true; |
| 611 | } |
| 612 | |
| 613 | @Override |
| 614 | public int hashCode() { |
| 615 | final int prime = 31; |
| 616 | int result = 1; |
| 617 | |
| 618 | result = prime * (int) (xid ^ (xid >>> 32)); |
| 619 | result = prime * result + ((bufferId == null) ? 0 : bufferId.hashCode()); |
| 620 | result = prime * result + totalLen; |
| 621 | result = prime * result + ((inPort == null) ? 0 : inPort.hashCode()); |
| 622 | result = prime * result + ((reason == null) ? 0 : reason.hashCode()); |
| 623 | result = prime * result + Arrays.hashCode(data); |
| 624 | return result; |
| 625 | } |
| 626 | |
| 627 | } |