public static Deserializer<RouterAdvertisement> deserializer() {
        return (data, offset, length) -> {
            checkInput(data, offset, length, HEADER_LENGTH);

            RouterAdvertisement routerAdvertisement = new RouterAdvertisement();

            ByteBuffer bb = ByteBuffer.wrap(data, offset, length);
            int bscratch;

            routerAdvertisement.currentHopLimit = bb.get();
            bscratch = bb.get();
            routerAdvertisement.mFlag = (byte) ((bscratch >> 7) & 0x1);
            routerAdvertisement.oFlag = (byte) ((bscratch >> 6) & 0x1);
            routerAdvertisement.routerLifetime = bb.getShort();
            routerAdvertisement.reachableTime = bb.getInt();
            routerAdvertisement.retransmitTimer = bb.getInt();

            if (bb.limit() - bb.position() > 0) {
                NeighborDiscoveryOptions options = NeighborDiscoveryOptions.deserializer()
                        .deserialize(data, bb.position(), bb.limit() - bb.position());

                for (NeighborDiscoveryOptions.Option option : options.options()) {
                    routerAdvertisement.addOption(option.type(), option.data());
                }
            }

            return routerAdvertisement;
        };
    }
@Test
    public void testDeserializeBadInput() throws Exception {
        PacketTestUtils.testDeserializeBadInput(RouterAdvertisement.deserializer());
    }