@Test public void testReadLengthUnavailable() { ByteBuffer buffer = ByteBuffer.allocate(20); buffer.flip(); int firstPacketLength = IPv4Header.readLength(buffer); Assert.assertEquals("IPv4 packet length must be unknown", -1, firstPacketLength); }
public static int readLength(ByteBuffer buffer) { if (buffer.limit() < 4) { return -1; } return Short.toUnsignedInt(buffer.getShort(2)); }
IPv4Header { public static int readLength(ByteBuffer buffer) { if (buffer.limit() < 4) { return -1; } return Short.toUnsignedInt(buffer.getShort(2)); } }
IPv4Header { public static int readLength(ByteBuffer buffer) { if (buffer.limit() < 4) { return -1; } return Short.toUnsignedInt(buffer.getShort(2)); } IPv4Header(ByteBuffer raw); }
IPv4Header { public static int readLength(ByteBuffer buffer) { if (buffer.limit() < 4) { return -1; } return Short.toUnsignedInt(buffer.getShort(2)); } IPv4Header(ByteBuffer raw); boolean isSupported(); Protocol getProtocol(); int getHeaderLength(); int getTotalLength(); void setTotalLength(int totalLength); int getSource(); int getDestination(); void setSource(int source); void setDestination(int destination); void swapSourceAndDestination(); ByteBuffer getRaw(); IPv4Header copyTo(ByteBuffer target); IPv4Header copy(); void computeChecksum(); short getChecksum(); static int readVersion(ByteBuffer buffer); static int readLength(ByteBuffer buffer); }
IPv4Header { public static int readLength(ByteBuffer buffer) { if (buffer.limit() < 4) { return -1; } return Short.toUnsignedInt(buffer.getShort(2)); } IPv4Header(ByteBuffer raw); boolean isSupported(); Protocol getProtocol(); int getHeaderLength(); int getTotalLength(); void setTotalLength(int totalLength); int getSource(); int getDestination(); void setSource(int source); void setDestination(int destination); void swapSourceAndDestination(); ByteBuffer getRaw(); IPv4Header copyTo(ByteBuffer target); IPv4Header copy(); void computeChecksum(); short getChecksum(); static int readVersion(ByteBuffer buffer); static int readLength(ByteBuffer buffer);  }