@Override public Packet newInstance(byte[] rawData, int offset, int length) throws IllegalRawDataException { return IcmpV4TimestampReplyPacket.newPacket(rawData, offset, length); }
@Override public IcmpV4TimestampReplyPacket build() { return new IcmpV4TimestampReplyPacket(this); } }
@Test public void testNewPacket() { try { IcmpV4TimestampReplyPacket p = IcmpV4TimestampReplyPacket.newPacket(packet.getRawData(), 0, packet.getRawData().length); assertEquals(packet, p); } catch (IllegalRawDataException e) { throw new AssertionError(e); } }
@Test public void testGetHeader() { IcmpV4TimestampReplyHeader h = packet.getHeader(); assertEquals(identifier, h.getIdentifier()); assertEquals(sequenceNumber, h.getSequenceNumber()); assertEquals(transmitTimestamp, h.getTransmitTimestamp()); IcmpV4TimestampReplyPacket.Builder b = packet.getBuilder(); IcmpV4TimestampReplyPacket p; b.sequenceNumber((short) 0); p = b.build(); assertEquals((short) 0, (short) p.getHeader().getIdentifierAsInt()); assertEquals((short) 0, (short) p.getHeader().getSequenceNumberAsInt()); assertEquals((short) 10000, (short) p.getHeader().getIdentifierAsInt()); assertEquals((short) 10000, (short) p.getHeader().getSequenceNumberAsInt()); assertEquals((short) 32767, (short) p.getHeader().getIdentifierAsInt()); assertEquals((short) 32767, (short) p.getHeader().getSequenceNumberAsInt()); assertEquals((short) -1, (short) p.getHeader().getIdentifierAsInt()); assertEquals((short) -1, (short) p.getHeader().getSequenceNumberAsInt()); assertEquals((short) -32768, (short) p.getHeader().getIdentifierAsInt()); assertEquals((short) -32768, (short) p.getHeader().getSequenceNumberAsInt());
@Override public Packet newInstance(byte[] rawData, int offset, int length) throws IllegalRawDataException { return IcmpV4TimestampReplyPacket.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 IcmpV4TimestampReplyPacket object. * @throws IllegalRawDataException if parsing the raw data fails. */ public static IcmpV4TimestampReplyPacket newPacket(byte[] rawData, int offset, int length) throws IllegalRawDataException { ByteArrays.validateBounds(rawData, offset, length); return new IcmpV4TimestampReplyPacket(rawData, offset, length); }
@Override public IcmpV4TimestampReplyPacket build() { return new IcmpV4TimestampReplyPacket(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 IcmpV4TimestampReplyPacket object. * @throws IllegalRawDataException if parsing the raw data fails. */ public static IcmpV4TimestampReplyPacket newPacket(byte[] rawData, int offset, int length) throws IllegalRawDataException { ByteArrays.validateBounds(rawData, offset, length); return new IcmpV4TimestampReplyPacket(rawData, offset, length); }