@Test public void testDeserialize() throws Exception { BaseOptions baseopt = deserializer.deserialize(bytePacket, 0, bytePacket.length); assertThat(baseopt.getNextHeader(), is((byte) 0x11)); assertThat(baseopt.getHeaderExtLength(), is((byte) 0x00)); assertArrayEquals(baseopt.getOptions(), options); }
@Override public IPacket deserialize(byte[] data, int offset, int length) { final ByteBuffer bb = ByteBuffer.wrap(data, offset, length); this.nextHeader = bb.get(); this.headerExtLength = bb.get(); int optionLength = FIXED_OPTIONS_LENGTH + LENGTH_UNIT * this.headerExtLength; this.options = new byte[optionLength]; bb.get(this.options, 0, optionLength); 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; }
BaseOptions 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(); this.headerExtLength = bb.get(); int optionLength = FIXED_OPTIONS_LENGTH + LENGTH_UNIT * this.headerExtLength; this.options = new byte[optionLength]; bb.get(this.options, 0, optionLength); 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; } }
BaseOptions 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(); this.headerExtLength = bb.get(); int optionLength = FIXED_OPTIONS_LENGTH + LENGTH_UNIT * this.headerExtLength; this.options = new byte[optionLength]; bb.get(this.options, 0, optionLength); 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; }  }
BaseOptions 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(); this.headerExtLength = bb.get(); int optionLength = FIXED_OPTIONS_LENGTH + LENGTH_UNIT * this.headerExtLength; this.options = new byte[optionLength]; bb.get(this.options, 0, optionLength); 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 BaseOptions setNextHeader(final byte nextHeader); byte getHeaderExtLength(); BaseOptions setHeaderExtLength(final byte headerExtLength); byte[] getOptions(); BaseOptions setOptions(final byte[] options); @Override byte[] serialize(); @Override IPacket deserialize(byte[] data, int offset, int length); @Override int hashCode(); @Override boolean equals(final Object obj); static Deserializer<BaseOptions> deserializer(); @Override String toString(); }
BaseOptions 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(); this.headerExtLength = bb.get(); int optionLength = FIXED_OPTIONS_LENGTH + LENGTH_UNIT * this.headerExtLength; this.options = new byte[optionLength]; bb.get(this.options, 0, optionLength); 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 BaseOptions setNextHeader(final byte nextHeader); byte getHeaderExtLength(); BaseOptions setHeaderExtLength(final byte headerExtLength); byte[] getOptions(); BaseOptions setOptions(final byte[] options); @Override byte[] serialize(); @Override IPacket deserialize(byte[] data, int offset, int length); @Override int hashCode(); @Override boolean equals(final Object obj); static Deserializer<BaseOptions> deserializer(); @Override String toString(); static final byte FIXED_HEADER_LENGTH; static final byte FIXED_OPTIONS_LENGTH; static final byte LENGTH_UNIT; }