def payload(self): """Payload of current instance.""" if self._extf: raise UnsupportedCall( f"'{self.__class__.__name__}' object has no attribute 'payload'" ) return self._next
def payload(self): """Payload of current instance.""" if self.extension: # pylint: disable=E1101 raise UnsupportedCall( f"'{self.__class__.__name__}' object has no attribute 'payload'" ) return self._next
def protocol(self): """Name of next layer protocol. Raises: UnsupportedCall: This protocol doesn't support :attr:`protocol`. """ raise UnsupportedCall(f"'{self.__class__.__name__}' object has no attribute 'protocol'")
def __index__(cls): """Numeral registry index of the protocol. Raises: UnsupportedCall: This protocol has no registry entry. """ raise UnsupportedCall(f'{cls.__name__!r} object cannot be interpreted as an integer')
def payload(self): """Payload of current instance. Raises: UnsupportedCall: This protocol doesn't support :attr:`payload`. """ raise UnsupportedCall("'Header' object has no attribute 'payload'")
def length(self): """Header length of current protocol. Raises: UnsupportedCall: This protocol doesn't support :attr:`length`. """ raise UnsupportedCall(f"'{self.__class__.__name__}' object has no attribute 'length'")
def protochain(self): """Protocol chain of current instance. Raises: UnsupportedCall: This protocol doesn't support :attr:`protochain`. """ raise UnsupportedCall("'Header' object has no attribute 'protochain'")
def dst(self): """Destination IP address. Raises: UnsupportedCall: This protocol doesn't support :attr:`dst`. """ raise UnsupportedCall( f"'{self.__class__.__name__}' object has no attribute 'dst'")
def src(self): """Source IP address. Raises: UnsupportedCall: This protocol doesn't support :attr:`src`. """ raise UnsupportedCall( f"'{self.__class__.__name__}' object has no attribute 'src'")
def _decode_next_layer(self, dict_, proto=None, length=None): """Decode next layer protocol. Raises: UnsupportedCall: This protocol doesn't support :meth:`_decode_next_layer`. """ raise UnsupportedCall( f"'{self.__class__.__name__}' object has no attribute '_decode_next_layer'" )
def _import_next_layer(self, proto, length=None): """Import next layer extractor. Raises: UnsupportedCall: This protocol doesn't support :meth:`_import_next_layer`. """ raise UnsupportedCall( f"'{self.__class__.__name__}' object has no attribute '_import_next_layer'" )
def payload(self): """Payload of current instance. Raises: UnsupportedCall: if the protocol is used as an IPv6 extension header :rtype: pcapkit.protocols.protocol.Protocol """ if self._extf: raise UnsupportedCall(f"'{self.__class__.__name__}' object has no attribute 'payload'") return self._next
def _import_next_layer(self, *args, **kwargs): # pylint: disable=arguments-differ """Import next layer extractor. Args: *args: arbitrary positional arguments Keyword Args: **kwargs: arbitrary keyword arguments Raises: UnsupportedCall: This protocol doesn't support :meth:`_import_next_layer`. """ raise UnsupportedCall(f"'{self.__class__.__name__}' object has no attribute '_import_next_layer'")
def _decode_next_layer(self, *args, **kwargs): # pylint: disable=signature-differs """Decode next layer protocol. Args: *args: arbitrary positional arguments Keyword Args: **kwargs: arbitrary keyword arguments Raises: UnsupportedCall: This protocol doesn't support :meth:`_decode_next_layer`. """ raise UnsupportedCall(f"'{self.__class__.__name__}' object has no attribute '_decode_next_layer'")
def __index__(self=None): """Index of the protocol. Returns: int: If the object is initiated, i.e. :attr:`self._fnum <pcapkit.protocols.pcap.frame.Frame._fnum>` exists, returns the frame index number of itself; else raises :exc:`UnsupportedCall`. Raises: UnsupportedCall: This protocol has no registry entry. """ if self is None: return 'Frame' if getattr(self, '_fnum', None) is None: raise UnsupportedCall( "'Frame' object cannot be interpreted as an integer") return self._fnum
def header(self): if self._exeng in ('scapy', 'pyshark'): raise UnsupportedCall( f"'Extractor(engine={self._exeng})' object has no attribute 'header'" ) return self._gbhdr
def info(self): if self._exeng in ('scapy', 'pyshark'): raise UnsupportedCall( f"'Extractor(engine={self._exeng})' object has no attribute 'info'" ) return self._vinfo
def protocol(self): """DEPRECATED""" raise UnsupportedCall( f"{self.__class__.__name__!r} object has no attribute 'protocol'")
def dst(self): """NotImplemented""" raise UnsupportedCall( f"'{self.__class__.__name__}' object has no attribute 'dst'")
def protocol(self): if self._flag_a: raise UnsupportedCall( f"'Extractor(auto=True)' object has no attribute 'protocol'") return self._proto
def length(self): """DEPRECATED""" raise UnsupportedCall( f"{self.__class__.__name__!r} object has no attribute 'length'")
def payload(self): """NotImplemented""" raise UnsupportedCall("'Header' object has no attribute 'payload'")
def protochain(self): """NotImplemented""" raise UnsupportedCall("'Header' object has no attribute 'protochain'")
def _decode_next_layer(self, dict_, proto=None, length=None): """Deprecated.""" raise UnsupportedCall(f"'{self.__class__.__name__}' object has no attribute '_decode_next_layer'")
def _import_next_layer(self, proto, length): """Deprecated.""" raise UnsupportedCall(f"'{self.__class__.__name__}' object has no attribute '_import_next_layer'")
def output(self): if self._flag_q: raise UnsupportedCall( "'Extractor(nofile=True)' object has no attribute 'format'") return self._ofnm
def length(self): """Deprecated.""" raise UnsupportedCall( f"'{self.__class__.__name__}' object has no attribute 'length'")
def _run_server(self, multiprocessing): """Use server multiprocessing to extract PCAP files.""" if not self._flag_m: raise UnsupportedCall( f"Extractor(engine={self._exeng})' has no attribute '_run_server'" ) if not self._flag_q: self._flag_q = True warnings.warn( "'Extractor(engine=pipeline)' does not support output; " f"'fout={self._ofnm}' ignored", AttributeWarning, stacklevel=stacklevel()) self._frnum = 1 # frame number (revised) self._expkg = multiprocessing # multiprocessing module self._mpsvc = NotImplemented # multiprocessing server process self._mpprc = list() # multiprocessing process list self._mpfdp = collections.defaultdict( multiprocessing.Queue) # multiprocessing file pointer self._mpmng = multiprocessing.Manager() # multiprocessing manager self._mpbuf = self._mpmng.dict() # multiprocessing frame dict self._mpfrm = self._mpmng.list() # multiprocessing frame storage self._mprsm = self._mpmng.list() # multiprocessing reassembly buffer self._mpkit = self._mpmng.Namespace() # multiprocessing work kit self._mpkit.counter = 0 # work count (on duty) self._mpkit.pool = 1 # work pool (ready) self._mpkit.eof = False # EOF flag self._mpkit.trace = None # flow tracer # preparation self.record_header() self._mpfdp[0].put(self._gbhdr.length) self._mpsvc = multiprocessing.Process( target=self._server_analyse_frame, kwargs={ 'mpfrm': self._mpfrm, 'mprsm': self._mprsm, 'mpbuf': self._mpbuf, 'mpkit': self._mpkit }) self._mpsvc.start() # extraction while True: # check EOF if self._mpkit.eof: self._update_eof() break # check counter if self._mpkit.pool and self._mpkit.counter < CPU_CNT - 1: # update file offset self._ifile.seek( self._mpfdp.pop(self._frnum - 1).get(), os.SEEK_SET) # create worker # print(self._frnum, 'start') proc = multiprocessing.Process( target=self._server_extract_frame, kwargs={ 'mpkit': self._mpkit, 'mpbuf': self._mpbuf, 'mpfdp': self._mpfdp[self._frnum] }) # update status self._mpkit.pool -= 1 self._mpkit.counter += 1 # start and record proc.start() self._frnum += 1 self._mpprc.append(proc) # check buffer if len(self._mpprc) >= CPU_CNT - 1: [proc.join() for proc in self._mpprc[:-4]] del self._mpprc[:-4]
def frame(self): if self._flag_d: return tuple(self._frame) raise UnsupportedCall( "'Extractor(store=False)' object has no attribute 'frame'")
def trace(self): if self._flag_t: return self._trace.index raise UnsupportedCall( "'Extractor(trace=False)' object has no attribute 'trace'")