@Test public void testDeserialize() throws DeserializationException { Fragment frag = deserializer.deserialize(bytePacket, 0, bytePacket.length); assertThat(frag.getNextHeader(), is((byte) 0x11)); assertThat(frag.getFragmentOffset(), is((short) 0x1f)); assertThat(frag.getMoreFragment(), is((byte) 1)); assertThat(frag.getIdentification(), is(0x1357)); }
@Override public IPacket deserialize(byte[] data, int offset, int length) { final ByteBuffer bb = ByteBuffer.wrap(data, offset, length); this.nextHeader = bb.get(); bb.get(); short sscratch = bb.getShort(); this.fragmentOffset = (short) (sscratch >> 3 & 0x1fff); this.moreFragment = (byte) (sscratch & 0x1); this.identification = bb.getInt(); Deserializer<? extends IPacket> deserializer; if (IPv6.PROTOCOL_DESERIALIZER_MAP.containsKey(this.nextHeader)) { deserializer = IPv6.PROTOCOL_DESERIALIZER_MAP.get(this.nextHeader); } else { deserializer = Data.deserializer(); } try { this.payload = deserializer.deserialize(data, bb.position(), bb.limit() - bb.position()); this.payload.setParent(this); } catch (DeserializationException e) { return this; } return this; }
Fragment extends BasePacket implements IExtensionHeader { @Override public IPacket deserialize(byte[] data, int offset, int length) { final ByteBuffer bb = ByteBuffer.wrap(data, offset, length); this.nextHeader = bb.get(); bb.get(); short sscratch = bb.getShort(); this.fragmentOffset = (short) (sscratch >> 3 & 0x1fff); this.moreFragment = (byte) (sscratch & 0x1); this.identification = bb.getInt(); Deserializer<? extends IPacket> deserializer; if (IPv6.PROTOCOL_DESERIALIZER_MAP.containsKey(this.nextHeader)) { deserializer = IPv6.PROTOCOL_DESERIALIZER_MAP.get(this.nextHeader); } else { deserializer = Data.deserializer(); } try { this.payload = deserializer.deserialize(data, bb.position(), bb.limit() - bb.position()); this.payload.setParent(this); } catch (DeserializationException e) { return this; } return this; } }
Fragment extends BasePacket implements IExtensionHeader { @Override public IPacket deserialize(byte[] data, int offset, int length) { final ByteBuffer bb = ByteBuffer.wrap(data, offset, length); this.nextHeader = bb.get(); bb.get(); short sscratch = bb.getShort(); this.fragmentOffset = (short) (sscratch >> 3 & 0x1fff); this.moreFragment = (byte) (sscratch & 0x1); this.identification = bb.getInt(); Deserializer<? extends IPacket> deserializer; if (IPv6.PROTOCOL_DESERIALIZER_MAP.containsKey(this.nextHeader)) { deserializer = IPv6.PROTOCOL_DESERIALIZER_MAP.get(this.nextHeader); } else { deserializer = Data.deserializer(); } try { this.payload = deserializer.deserialize(data, bb.position(), bb.limit() - bb.position()); this.payload.setParent(this); } catch (DeserializationException e) { return this; } return this; }  }
Fragment extends BasePacket implements IExtensionHeader { @Override public IPacket deserialize(byte[] data, int offset, int length) { final ByteBuffer bb = ByteBuffer.wrap(data, offset, length); this.nextHeader = bb.get(); bb.get(); short sscratch = bb.getShort(); this.fragmentOffset = (short) (sscratch >> 3 & 0x1fff); this.moreFragment = (byte) (sscratch & 0x1); this.identification = bb.getInt(); Deserializer<? extends IPacket> deserializer; if (IPv6.PROTOCOL_DESERIALIZER_MAP.containsKey(this.nextHeader)) { deserializer = IPv6.PROTOCOL_DESERIALIZER_MAP.get(this.nextHeader); } else { deserializer = Data.deserializer(); } try { this.payload = deserializer.deserialize(data, bb.position(), bb.limit() - bb.position()); this.payload.setParent(this); } catch (DeserializationException e) { return this; } return this; }  @Override byte getNextHeader(); @Override Fragment setNextHeader(final byte nextHeader); short getFragmentOffset(); Fragment setFragmentOffset(final short fragmentOffset); byte getMoreFragment(); Fragment setMoreFragment(final byte moreFragment); int getIdentification(); Fragment setIdentification(final int identification); @Override byte[] serialize(); @Override IPacket deserialize(byte[] data, int offset, int length); @Override int hashCode(); @Override boolean equals(final Object obj); static Deserializer<Fragment> deserializer(); @Override String toString(); }
Fragment extends BasePacket implements IExtensionHeader { @Override public IPacket deserialize(byte[] data, int offset, int length) { final ByteBuffer bb = ByteBuffer.wrap(data, offset, length); this.nextHeader = bb.get(); bb.get(); short sscratch = bb.getShort(); this.fragmentOffset = (short) (sscratch >> 3 & 0x1fff); this.moreFragment = (byte) (sscratch & 0x1); this.identification = bb.getInt(); Deserializer<? extends IPacket> deserializer; if (IPv6.PROTOCOL_DESERIALIZER_MAP.containsKey(this.nextHeader)) { deserializer = IPv6.PROTOCOL_DESERIALIZER_MAP.get(this.nextHeader); } else { deserializer = Data.deserializer(); } try { this.payload = deserializer.deserialize(data, bb.position(), bb.limit() - bb.position()); this.payload.setParent(this); } catch (DeserializationException e) { return this; } return this; }  @Override byte getNextHeader(); @Override Fragment setNextHeader(final byte nextHeader); short getFragmentOffset(); Fragment setFragmentOffset(final short fragmentOffset); byte getMoreFragment(); Fragment setMoreFragment(final byte moreFragment); int getIdentification(); Fragment setIdentification(final int identification); @Override byte[] serialize(); @Override IPacket deserialize(byte[] data, int offset, int length); @Override int hashCode(); @Override boolean equals(final Object obj); static Deserializer<Fragment> deserializer(); @Override String toString(); static final byte HEADER_LENGTH; }