@Override public Packet newInstance(byte[] rawData, int offset, int length) throws IllegalRawDataException { return IcmpV6MobilePrefixSolicitationPacket.newPacket(rawData, offset, length); }
@Override public IcmpV6MobilePrefixSolicitationPacket build() { return new IcmpV6MobilePrefixSolicitationPacket(this); } }
@Test public void testNewPacket() { IcmpV6MobilePrefixSolicitationPacket p; try { p = IcmpV6MobilePrefixSolicitationPacket.newPacket( packet.getRawData(), 0, packet.getRawData().length); assertEquals(packet, p); } catch (IllegalRawDataException e) { throw new AssertionError(e); } }
@Test public void testGetHeader() { IcmpV6MobilePrefixSolicitationHeader h = packet.getHeader(); assertEquals(identifier, h.getIdentifier()); assertEquals(reserved, h.getReserved()); IcmpV6MobilePrefixSolicitationPacket.Builder b = packet.getBuilder(); IcmpV6MobilePrefixSolicitationPacket p; b.identifier((short) 0); p = b.build(); assertEquals((short) 0, (short) p.getHeader().getIdentifierAsInt()); b.identifier((short) 10000); p = b.build(); assertEquals((short) 10000, (short) p.getHeader().getIdentifierAsInt()); b.identifier((short) 32767); p = b.build(); assertEquals((short) 32767, (short) p.getHeader().getIdentifierAsInt()); b.identifier((short) -1); p = b.build(); assertEquals((short) -1, (short) p.getHeader().getIdentifierAsInt()); b.identifier((short) -32768); p = b.build(); assertEquals((short) -32768, (short) p.getHeader().getIdentifierAsInt()); } }
@Override public Packet newInstance(byte[] rawData, int offset, int length) throws IllegalRawDataException { return IcmpV6MobilePrefixSolicitationPacket.newPacket(rawData, offset, length); }
/** * A static factory method. This method validates the arguments by {@link * ByteArrays#validateBounds(byte[], int, int)}, which may throw exceptions undocumented here. * * @param rawData rawData * @param offset offset * @param length length * @return a new IcmpV6MobilePrefixSolicitationPacket object. * @throws IllegalRawDataException if parsing the raw data fails. */ public static IcmpV6MobilePrefixSolicitationPacket newPacket( byte[] rawData, int offset, int length) throws IllegalRawDataException { ByteArrays.validateBounds(rawData, offset, length); return new IcmpV6MobilePrefixSolicitationPacket(rawData, offset, length); }
@Override public IcmpV6MobilePrefixSolicitationPacket build() { return new IcmpV6MobilePrefixSolicitationPacket(this); } }
/** * A static factory method. This method validates the arguments by {@link * ByteArrays#validateBounds(byte[], int, int)}, which may throw exceptions undocumented here. * * @param rawData rawData * @param offset offset * @param length length * @return a new IcmpV6MobilePrefixSolicitationPacket object. * @throws IllegalRawDataException if parsing the raw data fails. */ public static IcmpV6MobilePrefixSolicitationPacket newPacket( byte[] rawData, int offset, int length) throws IllegalRawDataException { ByteArrays.validateBounds(rawData, offset, length); return new IcmpV6MobilePrefixSolicitationPacket(rawData, offset, length); }