@Override
    public PCapPacket frame(final Packet parent, final Buffer buffer) throws IOException {

        // note that for the PcapPacket the parent will always be null
        // so we are simply ignoring it.
        Buffer record = null;
        try {
            record = buffer.readBytes(16);
        } catch (final IndexOutOfBoundsException e) {
            // we def want to do something nicer than exit
            // on an exception like this. For now, good enough
            return null;
        }

        final PcapRecordHeader header = new PcapRecordHeader(this.byteOrder, record, this.globalHeader.timestampsInNs());
        final int length = (int) header.getCapturedLength();
        if (length < 0) {
            throw new FramingException(String.format("Invalid PCAP captured length of %d", length), Protocol.PCAP);
        }
        final int total = (int) header.getTotalLength();
        final Buffer payload = buffer.readBytes(Math.min(length, total));
        return new PCapPacketImpl(globalHeader, header, payload);
    }
@ Override public PCapPacket frame ( final Packet parent , final Buffer buffer ) throws IOException { Buffer record = null ; try { record = buffer . readBytes ( 16 ) ; } catch ( final IndexOutOfBoundsException e ) { return null ; } final PcapRecordHeader header = new PcapRecordHeader ( this . byteOrder , record , this . globalHeader . timestampsInNs ( ) ) ; final int length = ( int ) header . getCapturedLength ( ) ; if ( length < 0 ) { throw new FramingException ( String . format ( "Invalid PCAP captured length of %d" , length ) , Protocol . PCAP ) ; } final int total = ( int ) header . getTotalLength ( ) ; final Buffer payload = buffer . readBytes ( Math . min ( length , total ) ) ; return new PCapPacketImpl ( globalHeader , header , payload ) ; }
{@inheritDoc}