@Test public void testSerialize() { Routing routing = new Routing(); routing.setNextHeader((byte) 0x11); routing.setHeaderExtLength((byte) 0x02); routing.setRoutingType((byte) 0x00); routing.setSegmntsLeft((byte) 0x03); routing.setRoutingData(routingData); routing.setPayload(udp); assertArrayEquals(routing.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 + routingData.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.headerExtLength); bb.put(this.routingType); bb.put(this.segmentsLeft); bb.put(this.routingData, 0, routingData.length); if (payloadData != null) { bb.put(payloadData); } if (this.parent != null && this.parent instanceof IExtensionHeader) { ((IExtensionHeader) this.parent).setNextHeader(IPv6.PROTOCOL_ROUTING); } return data; }
Routing 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 + routingData.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.headerExtLength); bb.put(this.routingType); bb.put(this.segmentsLeft); bb.put(this.routingData, 0, routingData.length); if (payloadData != null) { bb.put(payloadData); } if (this.parent != null && this.parent instanceof IExtensionHeader) { ((IExtensionHeader) this.parent).setNextHeader(IPv6.PROTOCOL_ROUTING); } return data; } }
Routing 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 + routingData.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.headerExtLength); bb.put(this.routingType); bb.put(this.segmentsLeft); bb.put(this.routingData, 0, routingData.length); if (payloadData != null) { bb.put(payloadData); } if (this.parent != null && this.parent instanceof IExtensionHeader) { ((IExtensionHeader) this.parent).setNextHeader(IPv6.PROTOCOL_ROUTING); } return data; }  }
Routing 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 + routingData.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.headerExtLength); bb.put(this.routingType); bb.put(this.segmentsLeft); bb.put(this.routingData, 0, routingData.length); if (payloadData != null) { bb.put(payloadData); } if (this.parent != null && this.parent instanceof IExtensionHeader) { ((IExtensionHeader) this.parent).setNextHeader(IPv6.PROTOCOL_ROUTING); } return data; }  @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 byte[] serialize() { byte[] payloadData = null; if (this.payload != null) { this.payload.setParent(this); payloadData = this.payload.serialize(); } int headerLength = FIXED_HEADER_LENGTH + routingData.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.headerExtLength); bb.put(this.routingType); bb.put(this.segmentsLeft); bb.put(this.routingData, 0, routingData.length); if (payloadData != null) { bb.put(payloadData); } if (this.parent != null && this.parent instanceof IExtensionHeader) { ((IExtensionHeader) this.parent).setNextHeader(IPv6.PROTOCOL_ROUTING); } return data; }  @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; }