@Test public void testDeserializeTruncated() throws Exception { byte[] raHeader = new byte[RouterAdvertisement.HEADER_LENGTH]; ByteBuffer.wrap(bytePacket).get(raHeader); PacketTestUtils.testDeserializeTruncated(RouterAdvertisement.deserializer(), raHeader); }
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; }; }
RouterAdvertisement extends BasePacket { 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; }; } }
RouterAdvertisement extends BasePacket { 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; }; }  }
RouterAdvertisement extends BasePacket { 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; }; }  byte getCurrentHopLimit(); RouterAdvertisement setCurrentHopLimit(final byte currentHopLimit); byte getMFlag(); RouterAdvertisement setMFlag(final byte mFlag); byte getOFlag(); RouterAdvertisement setOFlag(final byte oFlag); short getRouterLifetime(); RouterAdvertisement setRouterLifetime(final short routerLifetime); int getReachableTime(); RouterAdvertisement setReachableTime(final int reachableTime); int getRetransmitTimer(); RouterAdvertisement setRetransmitTimer(final int retransmitTimer); List<NeighborDiscoveryOptions.Option> getOptions(); RouterAdvertisement 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<RouterAdvertisement> deserializer(); @Override String toString(); }
RouterAdvertisement extends BasePacket { 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; }; }  byte getCurrentHopLimit(); RouterAdvertisement setCurrentHopLimit(final byte currentHopLimit); byte getMFlag(); RouterAdvertisement setMFlag(final byte mFlag); byte getOFlag(); RouterAdvertisement setOFlag(final byte oFlag); short getRouterLifetime(); RouterAdvertisement setRouterLifetime(final short routerLifetime); int getReachableTime(); RouterAdvertisement setReachableTime(final int reachableTime); int getRetransmitTimer(); RouterAdvertisement setRetransmitTimer(final int retransmitTimer); List<NeighborDiscoveryOptions.Option> getOptions(); RouterAdvertisement 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<RouterAdvertisement> deserializer(); @Override String toString(); static final byte HEADER_LENGTH; }