@Test public void testSerialize() { Authentication auth = new Authentication(); auth.setNextHeader((byte) 0x11); auth.setPayloadLength((byte) 0x02); auth.setSecurityParamIndex(0x13572468); auth.setSequence(0xffff00); auth.setIngegrityCheck(icv); auth.setPayload(udp); assertArrayEquals(auth.serialize(), bytePacket); }
@Override public byte[] serialize() { byte[] payloadData = null; if (this.payload != null) { this.payload.setParent(this); payloadData = this.payload.serialize(); } int headerLength = FIXED_HEADER_LENGTH + integrityCheck.length; int payloadLength = 0; if (payloadData != null) { payloadLength = payloadData.length; } final byte[] data = new byte[headerLength + payloadLength]; final ByteBuffer bb = ByteBuffer.wrap(data); bb.put(this.nextHeader); bb.put(this.payloadLength); bb.putShort((short) 0); bb.putInt(this.securityParamIndex); bb.putInt(this.sequence); bb.put(this.integrityCheck, 0, integrityCheck.length); if (payloadData != null) { bb.put(payloadData); } if (this.parent != null && this.parent instanceof IExtensionHeader) { ((IExtensionHeader) this.parent).setNextHeader(IPv6.PROTOCOL_AH); } return data; }
Authentication extends BasePacket implements IExtensionHeader { @Override public byte[] serialize() { byte[] payloadData = null; if (this.payload != null) { this.payload.setParent(this); payloadData = this.payload.serialize(); } int headerLength = FIXED_HEADER_LENGTH + integrityCheck.length; int payloadLength = 0; if (payloadData != null) { payloadLength = payloadData.length; } final byte[] data = new byte[headerLength + payloadLength]; final ByteBuffer bb = ByteBuffer.wrap(data); bb.put(this.nextHeader); bb.put(this.payloadLength); bb.putShort((short) 0); bb.putInt(this.securityParamIndex); bb.putInt(this.sequence); bb.put(this.integrityCheck, 0, integrityCheck.length); if (payloadData != null) { bb.put(payloadData); } if (this.parent != null && this.parent instanceof IExtensionHeader) { ((IExtensionHeader) this.parent).setNextHeader(IPv6.PROTOCOL_AH); } return data; } }
Authentication extends BasePacket implements IExtensionHeader { @Override public byte[] serialize() { byte[] payloadData = null; if (this.payload != null) { this.payload.setParent(this); payloadData = this.payload.serialize(); } int headerLength = FIXED_HEADER_LENGTH + integrityCheck.length; int payloadLength = 0; if (payloadData != null) { payloadLength = payloadData.length; } final byte[] data = new byte[headerLength + payloadLength]; final ByteBuffer bb = ByteBuffer.wrap(data); bb.put(this.nextHeader); bb.put(this.payloadLength); bb.putShort((short) 0); bb.putInt(this.securityParamIndex); bb.putInt(this.sequence); bb.put(this.integrityCheck, 0, integrityCheck.length); if (payloadData != null) { bb.put(payloadData); } if (this.parent != null && this.parent instanceof IExtensionHeader) { ((IExtensionHeader) this.parent).setNextHeader(IPv6.PROTOCOL_AH); } return data; }  }
Authentication extends BasePacket implements IExtensionHeader { @Override public byte[] serialize() { byte[] payloadData = null; if (this.payload != null) { this.payload.setParent(this); payloadData = this.payload.serialize(); } int headerLength = FIXED_HEADER_LENGTH + integrityCheck.length; int payloadLength = 0; if (payloadData != null) { payloadLength = payloadData.length; } final byte[] data = new byte[headerLength + payloadLength]; final ByteBuffer bb = ByteBuffer.wrap(data); bb.put(this.nextHeader); bb.put(this.payloadLength); bb.putShort((short) 0); bb.putInt(this.securityParamIndex); bb.putInt(this.sequence); bb.put(this.integrityCheck, 0, integrityCheck.length); if (payloadData != null) { bb.put(payloadData); } if (this.parent != null && this.parent instanceof IExtensionHeader) { ((IExtensionHeader) this.parent).setNextHeader(IPv6.PROTOCOL_AH); } return data; }  @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 byte[] serialize() { byte[] payloadData = null; if (this.payload != null) { this.payload.setParent(this); payloadData = this.payload.serialize(); } int headerLength = FIXED_HEADER_LENGTH + integrityCheck.length; int payloadLength = 0; if (payloadData != null) { payloadLength = payloadData.length; } final byte[] data = new byte[headerLength + payloadLength]; final ByteBuffer bb = ByteBuffer.wrap(data); bb.put(this.nextHeader); bb.put(this.payloadLength); bb.putShort((short) 0); bb.putInt(this.securityParamIndex); bb.putInt(this.sequence); bb.put(this.integrityCheck, 0, integrityCheck.length); if (payloadData != null) { bb.put(payloadData); } if (this.parent != null && this.parent instanceof IExtensionHeader) { ((IExtensionHeader) this.parent).setNextHeader(IPv6.PROTOCOL_AH); } return data; }  @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; }