IPv6PacketImpl extends AbstractPacket implements IPv6Packet { @Override public boolean isFragmented() { return (getHeader(EXTENSION_FRAGMENT) != null); } IPv6PacketImpl(final Packet parent, final Buffer headers, final int nextProtocol, final Buffer payload); @Override byte[] getRawSourceIP(); @Override void setSourceIP(final String sourceIp); @Override String getSourceIP(); @Override byte[] getRawDestinationIP(); @Override void setDestinationIP(final String destinationIP); @Override String getDestinationIP(); @Override void verify(); @Override long getArrivalTime(); @Override void write(final OutputStream out, final Buffer payload); @Override int getTotalIPLength(); void setRawSourceIP(final byte[] ip); void setRawDestinationIP(final byte[] ip); @Override IPv6Packet clone(); @Override Packet getNextPacket(); @Override int getVersion(); @Override int getHeaderLength(); @Override int getIdentification(); @Override boolean isFragmented(); @Override short getFragmentOffset(); @Override String toString(); static final int FIXED_HEADER_LENGTH; }
@Test public void isFragmented() throws Exception { List<Packet> packets = loadStream("ipv6_frag.pcap"); List<IPv6Packet> ipPackets = packets.stream().map(p -> { try { return (IPv6Packet) p.getPacket(Protocol.IPv6); } catch (IOException e) { return null; } }).collect(Collectors.toList()); assertTrue(ipPackets.get(0).isFragmented()); assertEquals(0, ipPackets.get(0).getFragmentOffset()); assertTrue(ipPackets.get(1).isFragmented()); assertEquals(1232, ipPackets.get(1).getFragmentOffset()); assertTrue(ipPackets.get(2).isFragmented()); assertEquals(2464, ipPackets.get(2).getFragmentOffset()); assertTrue(ipPackets.get(3).isFragmented()); assertEquals(3696, ipPackets.get(3).getFragmentOffset()); assertTrue(ipPackets.get(4).isFragmented()); assertEquals(4928, ipPackets.get(4).getFragmentOffset()); }