@Test public void testDeserializeBadInput() throws Exception { PacketTestUtils.testDeserializeBadInput(NeighborAdvertisement.deserializer()); }
public static Deserializer<NeighborAdvertisement> deserializer() { return (data, offset, length) -> { checkInput(data, offset, length, HEADER_LENGTH); NeighborAdvertisement neighborAdvertisement = new NeighborAdvertisement(); ByteBuffer bb = ByteBuffer.wrap(data, offset, length); int iscratch; iscratch = bb.getInt(); neighborAdvertisement.routerFlag = (byte) (iscratch >> 31 & 0x1); neighborAdvertisement.solicitedFlag = (byte) (iscratch >> 30 & 0x1); neighborAdvertisement.overrideFlag = (byte) (iscratch >> 29 & 0x1); bb.get(neighborAdvertisement.targetAddress, 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()) { neighborAdvertisement.addOption(option.type(), option.data()); } } return neighborAdvertisement; }; }
NeighborAdvertisement extends BasePacket { public static Deserializer<NeighborAdvertisement> deserializer() { return (data, offset, length) -> { checkInput(data, offset, length, HEADER_LENGTH); NeighborAdvertisement neighborAdvertisement = new NeighborAdvertisement(); ByteBuffer bb = ByteBuffer.wrap(data, offset, length); int iscratch; iscratch = bb.getInt(); neighborAdvertisement.routerFlag = (byte) (iscratch >> 31 & 0x1); neighborAdvertisement.solicitedFlag = (byte) (iscratch >> 30 & 0x1); neighborAdvertisement.overrideFlag = (byte) (iscratch >> 29 & 0x1); bb.get(neighborAdvertisement.targetAddress, 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()) { neighborAdvertisement.addOption(option.type(), option.data()); } } return neighborAdvertisement; }; } }
NeighborAdvertisement extends BasePacket { public static Deserializer<NeighborAdvertisement> deserializer() { return (data, offset, length) -> { checkInput(data, offset, length, HEADER_LENGTH); NeighborAdvertisement neighborAdvertisement = new NeighborAdvertisement(); ByteBuffer bb = ByteBuffer.wrap(data, offset, length); int iscratch; iscratch = bb.getInt(); neighborAdvertisement.routerFlag = (byte) (iscratch >> 31 & 0x1); neighborAdvertisement.solicitedFlag = (byte) (iscratch >> 30 & 0x1); neighborAdvertisement.overrideFlag = (byte) (iscratch >> 29 & 0x1); bb.get(neighborAdvertisement.targetAddress, 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()) { neighborAdvertisement.addOption(option.type(), option.data()); } } return neighborAdvertisement; }; }  }
NeighborAdvertisement extends BasePacket { public static Deserializer<NeighborAdvertisement> deserializer() { return (data, offset, length) -> { checkInput(data, offset, length, HEADER_LENGTH); NeighborAdvertisement neighborAdvertisement = new NeighborAdvertisement(); ByteBuffer bb = ByteBuffer.wrap(data, offset, length); int iscratch; iscratch = bb.getInt(); neighborAdvertisement.routerFlag = (byte) (iscratch >> 31 & 0x1); neighborAdvertisement.solicitedFlag = (byte) (iscratch >> 30 & 0x1); neighborAdvertisement.overrideFlag = (byte) (iscratch >> 29 & 0x1); bb.get(neighborAdvertisement.targetAddress, 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()) { neighborAdvertisement.addOption(option.type(), option.data()); } } return neighborAdvertisement; }; }  byte getRouterFlag(); NeighborAdvertisement setRouterFlag(final byte routerFlag); byte getSolicitedFlag(); NeighborAdvertisement setSolicitedFlag(final byte solicitedFlag); byte getOverrideFlag(); NeighborAdvertisement setOverrideFlag(final byte overrideFlag); byte[] getTargetAddress(); NeighborAdvertisement setTargetAddress(final byte[] targetAddress); List<NeighborDiscoveryOptions.Option> getOptions(); NeighborAdvertisement 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<NeighborAdvertisement> deserializer(); @Override String toString(); }
NeighborAdvertisement extends BasePacket { public static Deserializer<NeighborAdvertisement> deserializer() { return (data, offset, length) -> { checkInput(data, offset, length, HEADER_LENGTH); NeighborAdvertisement neighborAdvertisement = new NeighborAdvertisement(); ByteBuffer bb = ByteBuffer.wrap(data, offset, length); int iscratch; iscratch = bb.getInt(); neighborAdvertisement.routerFlag = (byte) (iscratch >> 31 & 0x1); neighborAdvertisement.solicitedFlag = (byte) (iscratch >> 30 & 0x1); neighborAdvertisement.overrideFlag = (byte) (iscratch >> 29 & 0x1); bb.get(neighborAdvertisement.targetAddress, 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()) { neighborAdvertisement.addOption(option.type(), option.data()); } } return neighborAdvertisement; }; }  byte getRouterFlag(); NeighborAdvertisement setRouterFlag(final byte routerFlag); byte getSolicitedFlag(); NeighborAdvertisement setSolicitedFlag(final byte solicitedFlag); byte getOverrideFlag(); NeighborAdvertisement setOverrideFlag(final byte overrideFlag); byte[] getTargetAddress(); NeighborAdvertisement setTargetAddress(final byte[] targetAddress); List<NeighborDiscoveryOptions.Option> getOptions(); NeighborAdvertisement 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<NeighborAdvertisement> deserializer(); @Override String toString(); static final byte HEADER_LENGTH; }