def _scapy_read_frame(self):
        """Read frames with Scapy."""
        from pcapkit.toolkit.scapy import (ipv4_reassembly, ipv6_reassembly,
                                           packet2chain, packet2dict, tcp_reassembly,
                                           tcp_traceflow)

        # fetch Scapy packet
        packet = next(self._extmp)

        # verbose output
        self._frnum += 1
        self._proto = packet2chain(packet)
        if self._flag_v:
            print(f' - Frame {self._frnum:>3d}: {self._proto}')

        # write plist
        frnum = f'Frame {self._frnum}'
        if not self._flag_q:
            info = packet2dict(packet)
            if self._flag_f:
                ofile = self._ofile(f'{self._ofnm}/{frnum}.{self._fext}')
                ofile(info, name=frnum)
            else:
                self._ofile(info, name=frnum)

        # record frames
        if self._flag_d:
            # setattr(packet, 'packet2dict', packet2dict)
            # setattr(packet, 'packet2chain', packet2chain)
            self._frame.append(packet)

        # record fragments
        if self._ipv4:
            flag, data = ipv4_reassembly(packet, count=self._frnum)
            if flag:
                self._reasm[0](data)  # pylint: disable=E1102
        if self._ipv6:
            flag, data = ipv6_reassembly(packet, count=self._frnum)
            if flag:
                self._reasm[1](data)  # pylint: disable=E1102
        if self._tcp:
            flag, data = tcp_reassembly(packet, count=self._frnum)
            if flag:
                self._reasm[2](data)  # pylint: disable=E1102

        # trace flows
        if self._flag_t:
            flag, data = tcp_traceflow(packet, count=self._frnum)
            if flag:
                self._trace(data)

        return packet
def _scapy_read_frame ( self ) : from pcapkit . toolkit . scapy import ( ipv4_reassembly , ipv6_reassembly , packet2chain , packet2dict , tcp_reassembly , tcp_traceflow ) packet = next ( self . _extmp ) self . _frnum += 1 self . _proto = packet2chain ( packet ) if self . _flag_v : print ( f' - Frame {self._frnum:>3d}: {self._proto}' ) frnum = f'Frame {self._frnum}' if not self . _flag_q : info = packet2dict ( packet ) if self . _flag_f : ofile = self . _ofile ( f'{self._ofnm}/{frnum}.{self._fext}' ) ofile ( info , name = frnum ) else : self . _ofile ( info , name = frnum ) if self . _flag_d : self . _frame . append ( packet ) if self . _ipv4 : flag , data = ipv4_reassembly ( packet , count = self . _frnum ) if flag : self . _reasm [ 0 ] ( data ) if self . _ipv6 : flag , data = ipv6_reassembly ( packet , count = self . _frnum ) if flag : self . _reasm [ 1 ] ( data ) if self . _tcp : flag , data = tcp_reassembly ( packet , count = self . _frnum ) if flag : self . _reasm [ 2 ] ( data ) if self . _flag_t : flag , data = tcp_traceflow ( packet , count = self . _frnum ) if flag : self . _trace ( data ) return packet
Read frames with Scapy.