@Test public void testDeserialize() throws Exception { Authentication auth = deserializer.deserialize(bytePacket, 0, bytePacket.length); assertThat(auth.getNextHeader(), is((byte) 0x11)); assertThat(auth.getPayloadLength(), is((byte) 0x02)); assertThat(auth.getSecurityParamIndex(), is(0x13572468)); assertThat(auth.getSequence(), is(0xffff00)); assertArrayEquals(auth.getIntegrityCheck(), icv); }
@Override public IPacket deserialize(byte[] data, int offset, int length) { final ByteBuffer bb = ByteBuffer.wrap(data, offset, length); this.nextHeader = bb.get(); this.payloadLength = bb.get(); bb.getShort(); this.securityParamIndex = bb.getInt(); this.sequence = bb.getInt(); int icvLength = getTotalLength() - FIXED_HEADER_LENGTH; this.integrityCheck = new byte[icvLength]; bb.get(this.integrityCheck, 0, icvLength); 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; }
Authentication 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.payloadLength = bb.get(); bb.getShort(); this.securityParamIndex = bb.getInt(); this.sequence = bb.getInt(); int icvLength = getTotalLength() - FIXED_HEADER_LENGTH; this.integrityCheck = new byte[icvLength]; bb.get(this.integrityCheck, 0, icvLength); 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; } }
Authentication 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.payloadLength = bb.get(); bb.getShort(); this.securityParamIndex = bb.getInt(); this.sequence = bb.getInt(); int icvLength = getTotalLength() - FIXED_HEADER_LENGTH; this.integrityCheck = new byte[icvLength]; bb.get(this.integrityCheck, 0, icvLength); 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; }  }
Authentication 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.payloadLength = bb.get(); bb.getShort(); this.securityParamIndex = bb.getInt(); this.sequence = bb.getInt(); int icvLength = getTotalLength() - FIXED_HEADER_LENGTH; this.integrityCheck = new byte[icvLength]; bb.get(this.integrityCheck, 0, icvLength); 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 Authentication setNextHeader(final byte nextHeader); byte getPayloadLength(); Authentication setPayloadLength(final byte payloadLength); int getSecurityParamIndex(); Authentication setSecurityParamIndex(final int securityParamIndex); int getSequence(); Authentication setSequence(final int sequence); byte[] getIntegrityCheck(); Authentication setIngegrityCheck(final byte[] integrityCheck); int getTotalLength(); @Override byte[] serialize(); @Override IPacket deserialize(byte[] data, int offset, int length); @Override int hashCode(); @Override boolean equals(final Object obj); static Deserializer<Authentication> deserializer(); @Override String toString(); }
Authentication 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.payloadLength = bb.get(); bb.getShort(); this.securityParamIndex = bb.getInt(); this.sequence = bb.getInt(); int icvLength = getTotalLength() - FIXED_HEADER_LENGTH; this.integrityCheck = new byte[icvLength]; bb.get(this.integrityCheck, 0, icvLength); 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 Authentication setNextHeader(final byte nextHeader); byte getPayloadLength(); Authentication setPayloadLength(final byte payloadLength); int getSecurityParamIndex(); Authentication setSecurityParamIndex(final int securityParamIndex); int getSequence(); Authentication setSequence(final int sequence); byte[] getIntegrityCheck(); Authentication setIngegrityCheck(final byte[] integrityCheck); int getTotalLength(); @Override byte[] serialize(); @Override IPacket deserialize(byte[] data, int offset, int length); @Override int hashCode(); @Override boolean equals(final Object obj); static Deserializer<Authentication> deserializer(); @Override String toString(); static final byte FIXED_HEADER_LENGTH; static final byte LENGTH_UNIT; static final byte MINUS; }