@Test public void testDeserialize() throws DeserializationException { IPv6 ipv6 = deserializer.deserialize(bytePacket, 0, bytePacket.length); assertThat(ipv6.getVersion(), is((byte) 6)); assertThat(ipv6.getTrafficClass(), is((byte) 0x93)); assertThat(ipv6.getFlowLabel(), is(0x13579)); assertThat(ipv6.getNextHeader(), is(IPv6.PROTOCOL_UDP)); assertThat(ipv6.getHopLimit(), is((byte) 32)); assertArrayEquals(ipv6.getSourceAddress(), SOURCE_ADDRESS); assertArrayEquals(ipv6.getDestinationAddress(), DESTINATION_ADDRESS); }
@Override public IPacket deserialize(final byte[] data, final int offset, final int length) { final ByteBuffer bb = ByteBuffer.wrap(data, offset, length); int iscratch; iscratch = bb.getInt(); this.version = (byte) (iscratch >> 28 & 0xf); this.trafficClass = (byte) (iscratch >> 20 & 0xff); this.flowLabel = iscratch & 0xfffff; this.payloadLength = bb.getShort(); this.nextHeader = bb.get(); this.hopLimit = bb.get(); bb.get(this.sourceAddress, 0, Ip6Address.BYTE_LENGTH); bb.get(this.destinationAddress, 0, Ip6Address.BYTE_LENGTH); 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; }
IPv6 extends BasePacket implements IExtensionHeader { @Override public IPacket deserialize(final byte[] data, final int offset, final int length) { final ByteBuffer bb = ByteBuffer.wrap(data, offset, length); int iscratch; iscratch = bb.getInt(); this.version = (byte) (iscratch >> 28 & 0xf); this.trafficClass = (byte) (iscratch >> 20 & 0xff); this.flowLabel = iscratch & 0xfffff; this.payloadLength = bb.getShort(); this.nextHeader = bb.get(); this.hopLimit = bb.get(); bb.get(this.sourceAddress, 0, Ip6Address.BYTE_LENGTH); bb.get(this.destinationAddress, 0, Ip6Address.BYTE_LENGTH); 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; } }
IPv6 extends BasePacket implements IExtensionHeader { @Override public IPacket deserialize(final byte[] data, final int offset, final int length) { final ByteBuffer bb = ByteBuffer.wrap(data, offset, length); int iscratch; iscratch = bb.getInt(); this.version = (byte) (iscratch >> 28 & 0xf); this.trafficClass = (byte) (iscratch >> 20 & 0xff); this.flowLabel = iscratch & 0xfffff; this.payloadLength = bb.getShort(); this.nextHeader = bb.get(); this.hopLimit = bb.get(); bb.get(this.sourceAddress, 0, Ip6Address.BYTE_LENGTH); bb.get(this.destinationAddress, 0, Ip6Address.BYTE_LENGTH); 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; } IPv6(); }
IPv6 extends BasePacket implements IExtensionHeader { @Override public IPacket deserialize(final byte[] data, final int offset, final int length) { final ByteBuffer bb = ByteBuffer.wrap(data, offset, length); int iscratch; iscratch = bb.getInt(); this.version = (byte) (iscratch >> 28 & 0xf); this.trafficClass = (byte) (iscratch >> 20 & 0xff); this.flowLabel = iscratch & 0xfffff; this.payloadLength = bb.getShort(); this.nextHeader = bb.get(); this.hopLimit = bb.get(); bb.get(this.sourceAddress, 0, Ip6Address.BYTE_LENGTH); bb.get(this.destinationAddress, 0, Ip6Address.BYTE_LENGTH); 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; } IPv6(); byte getVersion(); IPv6 setVersion(final byte version); byte getTrafficClass(); IPv6 setTrafficClass(final byte trafficClass); int getFlowLabel(); IPv6 setFlowLabel(final int flowLabel); @Override byte getNextHeader(); @Override IPv6 setNextHeader(final byte nextHeader); byte getHopLimit(); IPv6 setHopLimit(final byte hopLimit); byte[] getSourceAddress(); IPv6 setSourceAddress(final byte[] sourceAddress); byte[] getDestinationAddress(); IPv6 setDestinationAddress(final byte[] destinationAddress); @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<IPv6> deserializer(); @Override String toString(); }
IPv6 extends BasePacket implements IExtensionHeader { @Override public IPacket deserialize(final byte[] data, final int offset, final int length) { final ByteBuffer bb = ByteBuffer.wrap(data, offset, length); int iscratch; iscratch = bb.getInt(); this.version = (byte) (iscratch >> 28 & 0xf); this.trafficClass = (byte) (iscratch >> 20 & 0xff); this.flowLabel = iscratch & 0xfffff; this.payloadLength = bb.getShort(); this.nextHeader = bb.get(); this.hopLimit = bb.get(); bb.get(this.sourceAddress, 0, Ip6Address.BYTE_LENGTH); bb.get(this.destinationAddress, 0, Ip6Address.BYTE_LENGTH); 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; } IPv6(); byte getVersion(); IPv6 setVersion(final byte version); byte getTrafficClass(); IPv6 setTrafficClass(final byte trafficClass); int getFlowLabel(); IPv6 setFlowLabel(final int flowLabel); @Override byte getNextHeader(); @Override IPv6 setNextHeader(final byte nextHeader); byte getHopLimit(); IPv6 setHopLimit(final byte hopLimit); byte[] getSourceAddress(); IPv6 setSourceAddress(final byte[] sourceAddress); byte[] getDestinationAddress(); IPv6 setDestinationAddress(final byte[] destinationAddress); @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<IPv6> deserializer(); @Override String toString(); static final byte FIXED_HEADER_LENGTH; static final byte PROTOCOL_TCP; static final byte PROTOCOL_UDP; static final byte PROTOCOL_ICMP6; static final byte PROTOCOL_HOPOPT; static final byte PROTOCOL_ROUTING; static final byte PROTOCOL_FRAG; static final byte PROTOCOL_ESP; static final byte PROTOCOL_AH; static final byte PROTOCOL_DSTOPT; static final Map<Byte, Deserializer<? extends IPacket>> PROTOCOL_DESERIALIZER_MAP; }