Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/source/pcapkit/foundation/engines/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ support.
builtin
3rdparty

All engines are implemented as :class:`~pcapkit.foundation.engines.engine.Engine`
All engines are implemented as :class:`~pcapkit.foundation.engines.engine.EngineBase`
subclasses, which are responsible for parsing the input files and extracting
the network packets for further processing. Below is a brief diagram of the
class hierarchy of :mod:`pcapkit.foundation.engines`:
Expand Down
2 changes: 1 addition & 1 deletion docs/source/pcapkit/foundation/reassembly/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ of IP and TCP packets.
ip/index
tcp

All reassembly classes are implemented as :class:`~pcapkit.foundation.reassembly.reassembly.Reassembly`
All reassembly classes are implemented as :class:`~pcapkit.foundation.reassembly.reassembly.ReassemblyBase`
subclasses, which are responsible for processing extracted packets and
reassemble the datagrams to a nonfragmented packet. Below is a brief
diagram of the class hierarchy of :mod:`pcapkit.foundation.reassembly`:
Expand Down
2 changes: 1 addition & 1 deletion docs/source/pcapkit/foundation/traceflow/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ for :mod:`pcapkit` package.
traceflow
tcp

All flow tracing classes are implemented as :class:`~pcapkit.foundation.traceflow.traceflow.TraceFlow`
All flow tracing classes are implemented as :class:`~pcapkit.foundation.traceflow.traceflow.TraceFlowBase`
subclasses, which are responsible for processing extracted packets and
follow the flow and/or stream to provide more insights. Below is a brief
diagram of the class hierarchy of :mod:`pcapkit.foundation.traceflow`:
Expand Down
2 changes: 1 addition & 1 deletion docs/source/pcapkit/protocols/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ with detailed implementation and methods.
application/index
misc/index

All protocol classes are implemented as :class:`~pcapkit.protocols.protocol.Protocol`
All protocol classes are implemented as :class:`~pcapkit.protocols.protocol.ProtocolBase`
subclasses, which are responsible for processing extracted binary packet data
and/or construct protocol packet from given information. Below is a brief
diagram of the class hierarchy of :mod:`pcapkit.protocols`:
Expand Down
4 changes: 2 additions & 2 deletions pcapkit/corekit/fields/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
from typing_extensions import Self

from pcapkit.corekit.fields.field import NoValueType
from pcapkit.protocols.protocol import ProtocolBase as Protocol
from pcapkit.protocols.protocol import ProtocolBase
from pcapkit.protocols.schema.schema import Schema

_TC = TypeVar('_TC')
_TS = TypeVar('_TS', bound='Schema')
_TP = TypeVar('_TP', bound='Protocol')
_TP = TypeVar('_TP', bound='ProtocolBase')
_TN = TypeVar('_TN', bound='NoValueType')


Expand Down
38 changes: 19 additions & 19 deletions pcapkit/corekit/protochain.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

from typing_extensions import Self

from pcapkit.protocols.protocol import ProtocolBase as Protocol
from pcapkit.protocols.protocol import ProtocolBase

__all__ = ['ProtoChain']

Expand All @@ -36,14 +36,14 @@ class ProtoChain(collections.abc.Sequence):
"""

#: Internal data storage for protocol chain.
__data__: 'tuple[tuple[str, Type[Protocol]], ...]'
__data__: 'tuple[tuple[str, Type[ProtocolBase]], ...]'

##########################################################################
# Properties.
##########################################################################

@cached_property
def protocols(self) -> 'tuple[Type[Protocol], ...]':
def protocols(self) -> 'tuple[Type[ProtocolBase], ...]':
"""List of protocols in the chain."""
return tuple(data[1] for data in self.__data__)

Expand All @@ -62,19 +62,19 @@ def chain(self) -> 'str':
##########################################################################

@classmethod
def from_list(cls, data: 'list[Protocol | Type[Protocol]]') -> 'Self':
def from_list(cls, data: 'list[ProtocolBase | Type[ProtocolBase]]') -> 'Self':
"""Create a protocol chain from a list.

Args:
data: Protocol chain list.

"""
from pcapkit.protocols.protocol import \
ProtocolBase as Protocol # pylint: disable=import-outside-toplevel
ProtocolBase # pylint: disable=import-outside-toplevel

temp_data = []
for proto in data:
if isinstance(proto, Protocol):
if isinstance(proto, ProtocolBase):
alias = proto.alias
proto = type(proto)
else:
Expand All @@ -86,7 +86,7 @@ def from_list(cls, data: 'list[Protocol | Type[Protocol]]') -> 'Self':
obj.__data__ = tuple(temp_data)
return obj

def index(self, value: 'str | Protocol | Type[Protocol]',
def index(self, value: 'str | ProtocolBase | Type[ProtocolBase]',
start: 'Optional[int]' = None, stop: 'Optional[int]' = None) -> 'int':
"""First index of ``value``.

Expand All @@ -109,8 +109,8 @@ def index(self, value: 'str | Protocol | Type[Protocol]',

# prepare comparison values
from pcapkit.protocols.protocol import \
ProtocolBase as Protocol # pylint: disable=import-outside-toplevel
comp = Protocol.expand_comp(value)
ProtocolBase # pylint: disable=import-outside-toplevel
comp = ProtocolBase.expand_comp(value)

pool = self.__data__[start:stop]
for idx, (alias, proto) in enumerate(pool):
Expand All @@ -120,7 +120,7 @@ def index(self, value: 'str | Protocol | Type[Protocol]',
return start + idx
raise IndexNotFound(f'{value!r} is not in {self.__class__.__name__!r}')

def count(self, value: 'str | Protocol | Type[Protocol]') -> int:
def count(self, value: 'str | ProtocolBase | Type[ProtocolBase]') -> int:
"""Number of occurrences of ``value``.

Args:
Expand All @@ -129,8 +129,8 @@ def count(self, value: 'str | Protocol | Type[Protocol]') -> int:
"""
# prepare comparison values
from pcapkit.protocols.protocol import \
ProtocolBase as Protocol # pylint: disable=import-outside-toplevel
comp = Protocol.expand_comp(value)
ProtocolBase # pylint: disable=import-outside-toplevel
comp = ProtocolBase.expand_comp(value)

cnt = 0
for alias, proto in self.__data__:
Expand All @@ -145,7 +145,7 @@ def count(self, value: 'str | Protocol | Type[Protocol]') -> int:
# Data models.
##########################################################################

def __init__(self, proto: 'Protocol | Type[Protocol]', alias: 'Optional[str]' = None, *,
def __init__(self, proto: 'ProtocolBase | Type[ProtocolBase]', alias: 'Optional[str]' = None, *,
basis: 'Optional[ProtoChain]' = None):
"""Initialisation.

Expand All @@ -156,8 +156,8 @@ def __init__(self, proto: 'Protocol | Type[Protocol]', alias: 'Optional[str]' =

"""
from pcapkit.protocols.protocol import \
ProtocolBase as Protocol # pylint: disable=import-outside-toplevel
if isinstance(proto, Protocol):
ProtocolBase # pylint: disable=import-outside-toplevel
if isinstance(proto, ProtocolBase):
if alias is None:
alias = proto.alias
proto = type(proto)
Expand Down Expand Up @@ -192,7 +192,7 @@ def __str__(self) -> 'str':
"""
return ':'.join(map(lambda p: p[0], self.__data__))

def __contains__(self, name: 'str | Protocol | Type[Protocol]') -> 'bool': # type: ignore[override]
def __contains__(self, name: 'str | ProtocolBase | Type[ProtocolBase]') -> 'bool': # type: ignore[override]
"""Returns if ``name`` is in the chain.

Args:
Expand All @@ -203,8 +203,8 @@ def __contains__(self, name: 'str | Protocol | Type[Protocol]') -> 'bool': # ty

"""
from pcapkit.protocols.protocol import \
ProtocolBase as Protocol # pylint: disable=import-outside-toplevel
comp = Protocol.expand_comp(name)
ProtocolBase # pylint: disable=import-outside-toplevel
comp = ProtocolBase.expand_comp(name)

for alias, proto in self.__data__:
test_comp = (proto, alias.upper(), *(name.upper() for name in proto.id()))
Expand Down Expand Up @@ -232,7 +232,7 @@ def __getitem__(self, index: 'int | slice') -> 'str | tuple[str, ...]':
return tuple(data[0] for data in self.__data__[index])
return self.__data__[index][0]

def __iter__(self) -> 'Iterator[tuple[str, Type[Protocol]]]':
def __iter__(self) -> 'Iterator[tuple[str, Type[ProtocolBase]]]':
"""Iterator support.

Returns:
Expand Down
4 changes: 2 additions & 2 deletions pcapkit/dumpkit/null.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"""
from typing import TYPE_CHECKING

from pcapkit.dumpkit.common import DumperBase as Dumper
from pcapkit.dumpkit.common import DumperBase

if TYPE_CHECKING:
from typing import IO, Any, Optional
Expand All @@ -25,7 +25,7 @@
__all__ = ['NotImplementedIO']


class NotImplementedIO(Dumper):
class NotImplementedIO(DumperBase):
"""Unspecified output format."""

##########################################################################
Expand Down
4 changes: 2 additions & 2 deletions pcapkit/dumpkit/pcap.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import sys
from typing import TYPE_CHECKING

from pcapkit.dumpkit.common import DumperBase as Dumper
from pcapkit.dumpkit.common import DumperBase
from pcapkit.protocols.data.misc.pcap.header import Header as Data_Header
from pcapkit.protocols.misc.pcap.header import Header

Expand Down Expand Up @@ -49,7 +49,7 @@
_UINT32_MASK = 0xFFFF_FFFF


class PCAPIO(Dumper):
class PCAPIO(DumperBase):
"""PCAP file dumper.

Args:
Expand Down
4 changes: 2 additions & 2 deletions pcapkit/foundation/engines/dpkt.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from typing import TYPE_CHECKING, cast

from pcapkit.const.reg.linktype import LinkType as Enum_LinkType
from pcapkit.foundation.engines.engine import EngineBase as Engine
from pcapkit.foundation.engines.engine import EngineBase
from pcapkit.utilities.exceptions import FormatError, stacklevel
from pcapkit.utilities.logging import get_logger
from pcapkit.utilities.warnings import AttributeWarning, DPKTWarning, warn
Expand All @@ -36,7 +36,7 @@
logger = get_logger(__name__)


class DPKT(Engine['DPKTPacket']):
class DPKT(EngineBase['DPKTPacket']):
"""DPKT engine support.

Args:
Expand Down
4 changes: 2 additions & 2 deletions pcapkit/foundation/engines/pcap.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"""
from typing import TYPE_CHECKING

from pcapkit.foundation.engines.engine import EngineBase as Engine
from pcapkit.foundation.engines.engine import EngineBase
from pcapkit.protocols.misc.pcap.frame import Frame
from pcapkit.protocols.misc.pcap.header import Header
from pcapkit.utilities.logging import get_logger
Expand All @@ -26,7 +26,7 @@
logger = get_logger(__name__)


class PCAP(Engine[Frame]):
class PCAP(EngineBase[Frame]):
"""PCAP file extraction support.

Args:
Expand Down
4 changes: 2 additions & 2 deletions pcapkit/foundation/engines/pcap_ct.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from pcapkit.const.reg.linktype import LinkType as Enum_LinkType
from pcapkit.foundation.engines import _pcap_backend
from pcapkit.foundation.engines.engine import EngineBase as Engine
from pcapkit.foundation.engines.engine import EngineBase
from pcapkit.foundation.reassembly import ReassemblyManager
from pcapkit.foundation.traceflow import TraceFlowManager
from pcapkit.utilities.exceptions import FormatError, UnsupportedCall, stacklevel
Expand All @@ -38,7 +38,7 @@
RawFrame = tuple[float, bytes]


class PCAP_CT(Engine['RawFrame']):
class PCAP_CT(EngineBase['RawFrame']):
"""pcap-ct engine support.

`pcap-ct`_ is a :mod:`ctypes` reimplementation of the `PyPCAP`_ API on top of
Expand Down
4 changes: 2 additions & 2 deletions pcapkit/foundation/engines/pcapng.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from pcapkit.const.pcapng.block_type import BlockType as Enum_BlockType
from pcapkit.corekit.infoclass import Info, info_final
from pcapkit.foundation.engines.engine import EngineBase as Engine
from pcapkit.foundation.engines.engine import EngineBase
from pcapkit.protocols.misc.pcapng import PCAPNG as P_PCAPNG
from pcapkit.utilities.exceptions import FormatError, stacklevel
from pcapkit.utilities.logging import get_logger
Expand Down Expand Up @@ -84,7 +84,7 @@ def __post_init__(self) -> None:
def __init__(self, section: 'Data_SectionHeaderBlock') -> 'None': ...


class PCAPNG(Engine[P_PCAPNG]):
class PCAPNG(EngineBase[P_PCAPNG]):
"""PCAP-NG file extraction support.

Args:
Expand Down
4 changes: 2 additions & 2 deletions pcapkit/foundation/engines/pypcap.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

from pcapkit.const.reg.linktype import LinkType as Enum_LinkType
from pcapkit.foundation.engines import _pcap_backend
from pcapkit.foundation.engines.engine import EngineBase as Engine
from pcapkit.foundation.engines.engine import EngineBase
from pcapkit.foundation.reassembly import ReassemblyManager
from pcapkit.foundation.traceflow import TraceFlowManager
from pcapkit.utilities.exceptions import FormatError, UnsupportedCall, stacklevel
Expand All @@ -44,7 +44,7 @@
RawFrame = tuple[float, bytes]


class PyPCAP(Engine['RawFrame']):
class PyPCAP(EngineBase['RawFrame']):
"""PyPCAP engine support.

`PyPCAP`_ is a binding over :manpage:`libpcap(3)`, primarily aimed at live
Expand Down
4 changes: 2 additions & 2 deletions pcapkit/foundation/engines/pypcapfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from typing import TYPE_CHECKING, cast

from pcapkit.const.reg.linktype import LinkType as Enum_LinkType
from pcapkit.foundation.engines.engine import EngineBase as Engine
from pcapkit.foundation.engines.engine import EngineBase
from pcapkit.foundation.reassembly import ReassemblyManager
from pcapkit.utilities.exceptions import FormatError, stacklevel
from pcapkit.utilities.warnings import AttributeWarning, warn
Expand Down Expand Up @@ -62,7 +62,7 @@ def read(self, size: 'int' = -1) -> 'bytes':
return self._stream.read(size)


class PyPCAPFile(Engine['PCAPFilePacket']):
class PyPCAPFile(EngineBase['PCAPFilePacket']):
"""PyPCAPFile engine support.

`PyPCAPFile`_ is a pure Python savefile reader. It decodes Ethernet, IPv4,
Expand Down
4 changes: 2 additions & 2 deletions pcapkit/foundation/engines/pyshark.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import sys
from typing import TYPE_CHECKING, cast

from pcapkit.foundation.engines.engine import EngineBase as Engine
from pcapkit.foundation.engines.engine import EngineBase
from pcapkit.foundation.reassembly import ReassemblyManager
from pcapkit.utilities.exceptions import stacklevel
from pcapkit.utilities.logging import get_logger
Expand All @@ -34,7 +34,7 @@
logger = get_logger(__name__)


class PyShark(Engine['PySharkPacket']):
class PyShark(EngineBase['PySharkPacket']):
"""PyShark engine support.

Args:
Expand Down
4 changes: 2 additions & 2 deletions pcapkit/foundation/engines/scapy.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"""
from typing import TYPE_CHECKING, cast

from pcapkit.foundation.engines.engine import EngineBase as Engine
from pcapkit.foundation.engines.engine import EngineBase
from pcapkit.utilities.exceptions import stacklevel
from pcapkit.utilities.logging import get_logger
from pcapkit.utilities.warnings import AttributeWarning, warn
Expand All @@ -58,7 +58,7 @@
logger = get_logger(__name__)


class Scapy(Engine['ScapyPacket']):
class Scapy(EngineBase['ScapyPacket']):
"""Scapy engine support.

Args:
Expand Down
Loading
Loading