@Test public void testDeserialize() throws Exception { TCP tcp = deserializer.deserialize(bytePacketTCP4, 0, bytePacketTCP4.length); assertThat(tcp.getSourcePort(), is(0x50)); assertThat(tcp.getDestinationPort(), is(0x60)); assertThat(tcp.getSequence(), is(0x10)); assertThat(tcp.getAcknowledge(), is(0x20)); assertThat(tcp.getDataOffset(), is((byte) 0x5)); assertThat(tcp.getFlags(), is((short) 0x2)); assertThat(tcp.getWindowSize(), is((short) 0x1000)); assertThat(tcp.getUrgentPointer(), is((short) 0x1)); assertThat(tcp.getChecksum(), is((short) 0x1bae)); }
@Override public IPacket deserialize(final byte[] data, final int offset, final int length) { final ByteBuffer bb = ByteBuffer.wrap(data, offset, length); this.sourcePort = (bb.getShort() & 0xffff); this.destinationPort = (bb.getShort() & 0xffff); this.sequence = bb.getInt(); this.acknowledge = bb.getInt(); this.flags = bb.getShort(); this.dataOffset = (byte) (this.flags >> 12 & 0xf); this.flags = (short) (this.flags & 0x1ff); this.windowSize = bb.getShort(); this.checksum = bb.getShort(); this.urgentPointer = bb.getShort(); if (this.dataOffset > 5) { int optLength = (this.dataOffset << 2) - 20; if (bb.limit() < bb.position() + optLength) { optLength = bb.limit() - bb.position(); } try { this.options = new byte[optLength]; bb.get(this.options, 0, optLength); } catch (final IndexOutOfBoundsException e) { this.options = null; } } this.payload = new Data(); this.payload = this.payload.deserialize(data, bb.position(), bb.limit() - bb.position()); this.payload.setParent(this); return this; }
TCP extends BasePacket { @Override public IPacket deserialize(final byte[] data, final int offset, final int length) { final ByteBuffer bb = ByteBuffer.wrap(data, offset, length); this.sourcePort = (bb.getShort() & 0xffff); this.destinationPort = (bb.getShort() & 0xffff); this.sequence = bb.getInt(); this.acknowledge = bb.getInt(); this.flags = bb.getShort(); this.dataOffset = (byte) (this.flags >> 12 & 0xf); this.flags = (short) (this.flags & 0x1ff); this.windowSize = bb.getShort(); this.checksum = bb.getShort(); this.urgentPointer = bb.getShort(); if (this.dataOffset > 5) { int optLength = (this.dataOffset << 2) - 20; if (bb.limit() < bb.position() + optLength) { optLength = bb.limit() - bb.position(); } try { this.options = new byte[optLength]; bb.get(this.options, 0, optLength); } catch (final IndexOutOfBoundsException e) { this.options = null; } } this.payload = new Data(); this.payload = this.payload.deserialize(data, bb.position(), bb.limit() - bb.position()); this.payload.setParent(this); return this; } }
TCP extends BasePacket { @Override public IPacket deserialize(final byte[] data, final int offset, final int length) { final ByteBuffer bb = ByteBuffer.wrap(data, offset, length); this.sourcePort = (bb.getShort() & 0xffff); this.destinationPort = (bb.getShort() & 0xffff); this.sequence = bb.getInt(); this.acknowledge = bb.getInt(); this.flags = bb.getShort(); this.dataOffset = (byte) (this.flags >> 12 & 0xf); this.flags = (short) (this.flags & 0x1ff); this.windowSize = bb.getShort(); this.checksum = bb.getShort(); this.urgentPointer = bb.getShort(); if (this.dataOffset > 5) { int optLength = (this.dataOffset << 2) - 20; if (bb.limit() < bb.position() + optLength) { optLength = bb.limit() - bb.position(); } try { this.options = new byte[optLength]; bb.get(this.options, 0, optLength); } catch (final IndexOutOfBoundsException e) { this.options = null; } } this.payload = new Data(); this.payload = this.payload.deserialize(data, bb.position(), bb.limit() - bb.position()); this.payload.setParent(this); return this; }  }
TCP extends BasePacket { @Override public IPacket deserialize(final byte[] data, final int offset, final int length) { final ByteBuffer bb = ByteBuffer.wrap(data, offset, length); this.sourcePort = (bb.getShort() & 0xffff); this.destinationPort = (bb.getShort() & 0xffff); this.sequence = bb.getInt(); this.acknowledge = bb.getInt(); this.flags = bb.getShort(); this.dataOffset = (byte) (this.flags >> 12 & 0xf); this.flags = (short) (this.flags & 0x1ff); this.windowSize = bb.getShort(); this.checksum = bb.getShort(); this.urgentPointer = bb.getShort(); if (this.dataOffset > 5) { int optLength = (this.dataOffset << 2) - 20; if (bb.limit() < bb.position() + optLength) { optLength = bb.limit() - bb.position(); } try { this.options = new byte[optLength]; bb.get(this.options, 0, optLength); } catch (final IndexOutOfBoundsException e) { this.options = null; } } this.payload = new Data(); this.payload = this.payload.deserialize(data, bb.position(), bb.limit() - bb.position()); this.payload.setParent(this); return this; }  int getSourcePort(); TCP setSourcePort(final int sourcePort); int getDestinationPort(); TCP setDestinationPort(final int destinationPort); short getChecksum(); TCP setChecksum(final short checksum); int getSequence(); TCP setSequence(final int seq); int getAcknowledge(); TCP setAcknowledge(final int ack); byte getDataOffset(); TCP setDataOffset(final byte offset); short getFlags(); TCP setFlags(final short flags); short getWindowSize(); TCP setWindowSize(final short windowSize); @Override void resetChecksum(); short getUrgentPointer(); TCP setUrgentPointer(final short urgentPointer); byte[] getOptions(); TCP setOptions(final byte[] options); @Override byte[] serialize(); @Override IPacket deserialize(final byte[] data, final int offset,
                               final int length); @Override int hashCode(); @Override boolean equals(final Object obj); static Deserializer<TCP> deserializer(); @Override String toString(); }
TCP extends BasePacket { @Override public IPacket deserialize(final byte[] data, final int offset, final int length) { final ByteBuffer bb = ByteBuffer.wrap(data, offset, length); this.sourcePort = (bb.getShort() & 0xffff); this.destinationPort = (bb.getShort() & 0xffff); this.sequence = bb.getInt(); this.acknowledge = bb.getInt(); this.flags = bb.getShort(); this.dataOffset = (byte) (this.flags >> 12 & 0xf); this.flags = (short) (this.flags & 0x1ff); this.windowSize = bb.getShort(); this.checksum = bb.getShort(); this.urgentPointer = bb.getShort(); if (this.dataOffset > 5) { int optLength = (this.dataOffset << 2) - 20; if (bb.limit() < bb.position() + optLength) { optLength = bb.limit() - bb.position(); } try { this.options = new byte[optLength]; bb.get(this.options, 0, optLength); } catch (final IndexOutOfBoundsException e) { this.options = null; } } this.payload = new Data(); this.payload = this.payload.deserialize(data, bb.position(), bb.limit() - bb.position()); this.payload.setParent(this); return this; }  int getSourcePort(); TCP setSourcePort(final int sourcePort); int getDestinationPort(); TCP setDestinationPort(final int destinationPort); short getChecksum(); TCP setChecksum(final short checksum); int getSequence(); TCP setSequence(final int seq); int getAcknowledge(); TCP setAcknowledge(final int ack); byte getDataOffset(); TCP setDataOffset(final byte offset); short getFlags(); TCP setFlags(final short flags); short getWindowSize(); TCP setWindowSize(final short windowSize); @Override void resetChecksum(); short getUrgentPointer(); TCP setUrgentPointer(final short urgentPointer); byte[] getOptions(); TCP setOptions(final byte[] options); @Override byte[] serialize(); @Override IPacket deserialize(final byte[] data, final int offset,
                               final int length); @Override int hashCode(); @Override boolean equals(final Object obj); static Deserializer<TCP> deserializer(); @Override String toString();  }