@Test public void testDeserializeTruncated() throws Exception { byte[] rdHeader = new byte[Redirect.HEADER_LENGTH]; ByteBuffer.wrap(bytePacket).get(rdHeader); PacketTestUtils.testDeserializeTruncated(Redirect.deserializer(), rdHeader); }
public static Deserializer<Redirect> deserializer() { return (data, offset, length) -> { checkInput(data, offset, length, HEADER_LENGTH); Redirect redirect = new Redirect(); ByteBuffer bb = ByteBuffer.wrap(data, offset, length); bb.getInt(); bb.get(redirect.targetAddress, 0, Ip6Address.BYTE_LENGTH); bb.get(redirect.destinationAddress, 0, Ip6Address.BYTE_LENGTH); if (bb.limit() - bb.position() > 0) { NeighborDiscoveryOptions options = NeighborDiscoveryOptions.deserializer() .deserialize(data, bb.position(), bb.limit() - bb.position()); for (NeighborDiscoveryOptions.Option option : options.options()) { redirect.addOption(option.type(), option.data()); } } return redirect; }; }
Redirect extends BasePacket { public static Deserializer<Redirect> deserializer() { return (data, offset, length) -> { checkInput(data, offset, length, HEADER_LENGTH); Redirect redirect = new Redirect(); ByteBuffer bb = ByteBuffer.wrap(data, offset, length); bb.getInt(); bb.get(redirect.targetAddress, 0, Ip6Address.BYTE_LENGTH); bb.get(redirect.destinationAddress, 0, Ip6Address.BYTE_LENGTH); if (bb.limit() - bb.position() > 0) { NeighborDiscoveryOptions options = NeighborDiscoveryOptions.deserializer() .deserialize(data, bb.position(), bb.limit() - bb.position()); for (NeighborDiscoveryOptions.Option option : options.options()) { redirect.addOption(option.type(), option.data()); } } return redirect; }; } }
Redirect extends BasePacket { public static Deserializer<Redirect> deserializer() { return (data, offset, length) -> { checkInput(data, offset, length, HEADER_LENGTH); Redirect redirect = new Redirect(); ByteBuffer bb = ByteBuffer.wrap(data, offset, length); bb.getInt(); bb.get(redirect.targetAddress, 0, Ip6Address.BYTE_LENGTH); bb.get(redirect.destinationAddress, 0, Ip6Address.BYTE_LENGTH); if (bb.limit() - bb.position() > 0) { NeighborDiscoveryOptions options = NeighborDiscoveryOptions.deserializer() .deserialize(data, bb.position(), bb.limit() - bb.position()); for (NeighborDiscoveryOptions.Option option : options.options()) { redirect.addOption(option.type(), option.data()); } } return redirect; }; }  }
Redirect extends BasePacket { public static Deserializer<Redirect> deserializer() { return (data, offset, length) -> { checkInput(data, offset, length, HEADER_LENGTH); Redirect redirect = new Redirect(); ByteBuffer bb = ByteBuffer.wrap(data, offset, length); bb.getInt(); bb.get(redirect.targetAddress, 0, Ip6Address.BYTE_LENGTH); bb.get(redirect.destinationAddress, 0, Ip6Address.BYTE_LENGTH); if (bb.limit() - bb.position() > 0) { NeighborDiscoveryOptions options = NeighborDiscoveryOptions.deserializer() .deserialize(data, bb.position(), bb.limit() - bb.position()); for (NeighborDiscoveryOptions.Option option : options.options()) { redirect.addOption(option.type(), option.data()); } } return redirect; }; }  byte[] getTargetAddress(); Redirect setTargetAddress(final byte[] targetAddress); byte[] getDestinationAddress(); Redirect setDestinationAddress(final byte[] destinationAddress); List<NeighborDiscoveryOptions.Option> getOptions(); Redirect addOption(final byte type, final byte[] data); @Override byte[] serialize(); @Override IPacket deserialize(byte[] data, int offset, int length); @Override int hashCode(); @Override boolean equals(final Object obj); static Deserializer<Redirect> deserializer(); @Override String toString(); }
Redirect extends BasePacket { public static Deserializer<Redirect> deserializer() { return (data, offset, length) -> { checkInput(data, offset, length, HEADER_LENGTH); Redirect redirect = new Redirect(); ByteBuffer bb = ByteBuffer.wrap(data, offset, length); bb.getInt(); bb.get(redirect.targetAddress, 0, Ip6Address.BYTE_LENGTH); bb.get(redirect.destinationAddress, 0, Ip6Address.BYTE_LENGTH); if (bb.limit() - bb.position() > 0) { NeighborDiscoveryOptions options = NeighborDiscoveryOptions.deserializer() .deserialize(data, bb.position(), bb.limit() - bb.position()); for (NeighborDiscoveryOptions.Option option : options.options()) { redirect.addOption(option.type(), option.data()); } } return redirect; }; }  byte[] getTargetAddress(); Redirect setTargetAddress(final byte[] targetAddress); byte[] getDestinationAddress(); Redirect setDestinationAddress(final byte[] destinationAddress); List<NeighborDiscoveryOptions.Option> getOptions(); Redirect addOption(final byte type, final byte[] data); @Override byte[] serialize(); @Override IPacket deserialize(byte[] data, int offset, int length); @Override int hashCode(); @Override boolean equals(final Object obj); static Deserializer<Redirect> deserializer(); @Override String toString(); static final byte HEADER_LENGTH; }