@Test public void testDeserialize() throws DeserializationException { Routing routing = deserializer.deserialize(bytePacket, 0, bytePacket.length); assertThat(routing.getNextHeader(), is((byte) 0x11)); assertThat(routing.getHeaderExtLength(), is((byte) 0x02)); assertThat(routing.getRoutingType(), is((byte) 0x00)); assertThat(routing.getSegmentsLeft(), is((byte) 0x03)); assertArrayEquals(routing.getRoutingData(), routingData); }
@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(); this.routingType = bb.get(); this.segmentsLeft = bb.get(); int dataLength = FIXED_ROUTING_DATA_LENGTH + LENGTH_UNIT * this.headerExtLength; this.routingData = new byte[dataLength]; bb.get(this.routingData, 0, dataLength); Deserializer<? extends IPacket> deserializer; if (IPv6.PROTOCOL_DESERIALIZER_MAP.containsKey(this.nextHeader)) { deserializer = IPv6.PROTOCOL_DESERIALIZER_MAP.get(this.nextHeader); } else { deserializer = new 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; }
Routing 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(); this.routingType = bb.get(); this.segmentsLeft = bb.get(); int dataLength = FIXED_ROUTING_DATA_LENGTH + LENGTH_UNIT * this.headerExtLength; this.routingData = new byte[dataLength]; bb.get(this.routingData, 0, dataLength); Deserializer<? extends IPacket> deserializer; if (IPv6.PROTOCOL_DESERIALIZER_MAP.containsKey(this.nextHeader)) { deserializer = IPv6.PROTOCOL_DESERIALIZER_MAP.get(this.nextHeader); } else { deserializer = new 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; } }
Routing 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(); this.routingType = bb.get(); this.segmentsLeft = bb.get(); int dataLength = FIXED_ROUTING_DATA_LENGTH + LENGTH_UNIT * this.headerExtLength; this.routingData = new byte[dataLength]; bb.get(this.routingData, 0, dataLength); Deserializer<? extends IPacket> deserializer; if (IPv6.PROTOCOL_DESERIALIZER_MAP.containsKey(this.nextHeader)) { deserializer = IPv6.PROTOCOL_DESERIALIZER_MAP.get(this.nextHeader); } else { deserializer = new 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; }  }
Routing 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(); this.routingType = bb.get(); this.segmentsLeft = bb.get(); int dataLength = FIXED_ROUTING_DATA_LENGTH + LENGTH_UNIT * this.headerExtLength; this.routingData = new byte[dataLength]; bb.get(this.routingData, 0, dataLength); Deserializer<? extends IPacket> deserializer; if (IPv6.PROTOCOL_DESERIALIZER_MAP.containsKey(this.nextHeader)) { deserializer = IPv6.PROTOCOL_DESERIALIZER_MAP.get(this.nextHeader); } else { deserializer = new 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 Routing setNextHeader(final byte nextHeader); byte getHeaderExtLength(); Routing setHeaderExtLength(final byte headerExtLength); byte getRoutingType(); Routing setRoutingType(final byte routingType); byte getSegmentsLeft(); Routing setSegmntsLeft(final byte segmentsLeft); byte[] getRoutingData(); Routing setRoutingData(final byte[] routingData); @Override byte[] serialize(); @Override IPacket deserialize(byte[] data, int offset, int length); @Override int hashCode(); @Override boolean equals(final Object obj); static Deserializer<Routing> deserializer(); @Override String toString(); }
Routing 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(); this.routingType = bb.get(); this.segmentsLeft = bb.get(); int dataLength = FIXED_ROUTING_DATA_LENGTH + LENGTH_UNIT * this.headerExtLength; this.routingData = new byte[dataLength]; bb.get(this.routingData, 0, dataLength); Deserializer<? extends IPacket> deserializer; if (IPv6.PROTOCOL_DESERIALIZER_MAP.containsKey(this.nextHeader)) { deserializer = IPv6.PROTOCOL_DESERIALIZER_MAP.get(this.nextHeader); } else { deserializer = new 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 Routing setNextHeader(final byte nextHeader); byte getHeaderExtLength(); Routing setHeaderExtLength(final byte headerExtLength); byte getRoutingType(); Routing setRoutingType(final byte routingType); byte getSegmentsLeft(); Routing setSegmntsLeft(final byte segmentsLeft); byte[] getRoutingData(); Routing setRoutingData(final byte[] routingData); @Override byte[] serialize(); @Override IPacket deserialize(byte[] data, int offset, int length); @Override int hashCode(); @Override boolean equals(final Object obj); static Deserializer<Routing> deserializer(); @Override String toString(); static final byte FIXED_HEADER_LENGTH; static final byte FIXED_ROUTING_DATA_LENGTH; static final byte LENGTH_UNIT; }