コード例 #1
0
 def payload(self):
     """Payload of current instance."""
     if self._extf:
         raise UnsupportedCall(
             f"'{self.__class__.__name__}' object has no attribute 'payload'"
         )
     return self._next
コード例 #2
0
ファイル: mh.py プロジェクト: lorenzatoandrea/PyPCAPKit
 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
コード例 #3
0
ファイル: null.py プロジェクト: ljouans/PyPCAPKit
    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'")
コード例 #4
0
ファイル: null.py プロジェクト: jeetbhatt-sys/PyPCAPKit
    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')
コード例 #5
0
    def payload(self):
        """Payload of current instance.

        Raises:
            UnsupportedCall: This protocol doesn't support :attr:`payload`.

        """
        raise UnsupportedCall("'Header' object has no attribute 'payload'")
コード例 #6
0
ファイル: null.py プロジェクト: ljouans/PyPCAPKit
    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'")
コード例 #7
0
    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'")
コード例 #8
0
ファイル: ipsec.py プロジェクト: jeetbhatt-sys/PyPCAPKit
    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'")
コード例 #9
0
ファイル: ipsec.py プロジェクト: jeetbhatt-sys/PyPCAPKit
    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'")
コード例 #10
0
    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'"
        )
コード例 #11
0
    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'"
        )
コード例 #12
0
    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
コード例 #13
0
ファイル: null.py プロジェクト: ljouans/PyPCAPKit
    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'")
コード例 #14
0
ファイル: null.py プロジェクト: jeetbhatt-sys/PyPCAPKit
    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'")
コード例 #15
0
ファイル: frame.py プロジェクト: JarryShaw/PyPCAPKit
    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
コード例 #16
0
ファイル: extraction.py プロジェクト: xuacker/PyPCAPKit
 def header(self):
     if self._exeng in ('scapy', 'pyshark'):
         raise UnsupportedCall(
             f"'Extractor(engine={self._exeng})' object has no attribute 'header'"
         )
     return self._gbhdr
コード例 #17
0
ファイル: extraction.py プロジェクト: xuacker/PyPCAPKit
 def info(self):
     if self._exeng in ('scapy', 'pyshark'):
         raise UnsupportedCall(
             f"'Extractor(engine={self._exeng})' object has no attribute 'info'"
         )
     return self._vinfo
コード例 #18
0
ファイル: raw.py プロジェクト: lorenzatoandrea/PyPCAPKit
 def protocol(self):
     """DEPRECATED"""
     raise UnsupportedCall(
         f"{self.__class__.__name__!r} object has no attribute 'protocol'")
コード例 #19
0
ファイル: ipsec.py プロジェクト: xuacker/PyPCAPKit
 def dst(self):
     """NotImplemented"""
     raise UnsupportedCall(
         f"'{self.__class__.__name__}' object has no attribute 'dst'")
コード例 #20
0
ファイル: extraction.py プロジェクト: xuacker/PyPCAPKit
 def protocol(self):
     if self._flag_a:
         raise UnsupportedCall(
             f"'Extractor(auto=True)' object has no attribute 'protocol'")
     return self._proto
コード例 #21
0
ファイル: raw.py プロジェクト: lorenzatoandrea/PyPCAPKit
 def length(self):
     """DEPRECATED"""
     raise UnsupportedCall(
         f"{self.__class__.__name__!r} object has no attribute 'length'")
コード例 #22
0
ファイル: header.py プロジェクト: lorenzatoandrea/PyPCAPKit
 def payload(self):
     """NotImplemented"""
     raise UnsupportedCall("'Header' object has no attribute 'payload'")
コード例 #23
0
ファイル: header.py プロジェクト: lorenzatoandrea/PyPCAPKit
 def protochain(self):
     """NotImplemented"""
     raise UnsupportedCall("'Header' object has no attribute 'protochain'")
コード例 #24
0
ファイル: header.py プロジェクト: lorenzatoandrea/PyPCAPKit
 def _decode_next_layer(self, dict_, proto=None, length=None):
     """Deprecated."""
     raise UnsupportedCall(f"'{self.__class__.__name__}' object has no attribute '_decode_next_layer'")
コード例 #25
0
ファイル: header.py プロジェクト: lorenzatoandrea/PyPCAPKit
 def _import_next_layer(self, proto, length):
     """Deprecated."""
     raise UnsupportedCall(f"'{self.__class__.__name__}' object has no attribute '_import_next_layer'")
コード例 #26
0
ファイル: extraction.py プロジェクト: xuacker/PyPCAPKit
 def output(self):
     if self._flag_q:
         raise UnsupportedCall(
             "'Extractor(nofile=True)' object has no attribute 'format'")
     return self._ofnm
コード例 #27
0
ファイル: http.py プロジェクト: lorenzatoandrea/PyPCAPKit
 def length(self):
     """Deprecated."""
     raise UnsupportedCall(
         f"'{self.__class__.__name__}' object has no attribute 'length'")
コード例 #28
0
ファイル: extraction.py プロジェクト: xuacker/PyPCAPKit
    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]
コード例 #29
0
ファイル: extraction.py プロジェクト: xuacker/PyPCAPKit
 def frame(self):
     if self._flag_d:
         return tuple(self._frame)
     raise UnsupportedCall(
         "'Extractor(store=False)' object has no attribute 'frame'")
コード例 #30
0
ファイル: extraction.py プロジェクト: xuacker/PyPCAPKit
 def trace(self):
     if self._flag_t:
         return self._trace.index
     raise UnsupportedCall(
         "'Extractor(trace=False)' object has no attribute 'trace'")