Source code for pcapkit.protocols.application.application
# -*- coding: utf-8 -*-"""Base Protocol===================.. module:: pcapkit.protocols.application.application:mod:`pcapkit.protocols.application.application` contains only:class:`~pcapkit.protocols.application.application.Application`,which is a base class for application layer protocols, eg.:class:`HTTP/1.* <pcapkit.protocols.application.application.httpv1>`,:class:`HTTP/2 <pcapkit.protocols.application.application.httpv2>`and etc."""fromtypingimportTYPE_CHECKING,Generic,overloadfrompcapkit.corekit.protochainimportProtoChainfrompcapkit.protocols.misc.nullimportNoPayloadfrompcapkit.protocols.protocolimport_PT,_STfrompcapkit.protocols.protocolimportProtocolBaseasProtocolfrompcapkit.utilities.exceptionsimportIntError,UnsupportedCallifTYPE_CHECKING:fromtypingimportIO,Any,NoReturn,Optionalfromtyping_extensionsimportLiteral__all__=['Application']
[docs]classApplication(Protocol[_PT,_ST],Generic[_PT,_ST]):# pylint: disable=abstract-method"""Abstract base class for transport layer protocol family."""########################################################################### Defaults.###########################################################################: Layer of protocol.__layer__='Application'# type: Literal['Application']########################################################################### Properties.########################################################################### protocol layer@propertydeflayer(self)->'Literal["Application"]':"""Protocol layer."""returnself.__layer__########################################################################### Data models.##########################################################################@overloaddef__post_init__(self,file:'IO[bytes] | bytes',length:'Optional[int]'=...,**kwargs:'Any')->'None':...@overloaddef__post_init__(self,**kwargs:'Any')->'None':...
[docs]def__post_init__(self,file:'Optional[IO[bytes] | bytes]'=None,length:'Optional[int]'=None,**kwargs:'Any')->'None':"""Post initialisation hook. Args: file: Source packet stream. length: Length of packet data. **kwargs: Arbitrary keyword arguments. See Also: For construction arguments, please refer to :meth:`self.make <pcapkit.protocols.protocol.Protocol.make>`. """# call super post-initsuper().__post_init__(file,length,**kwargs)# type: ignore[arg-type]#: pcapkit.protocols.null.NoPayload: Payload of current instance.self._next=NoPayload()#: pcapkit.corekit.protochain.ProtoChain: Protocol chain of current instance.self._protos=ProtoChain(self.__class__,self.alias)
[docs]@classmethoddef__index__(cls)->'NoReturn':# pylint: disable=invalid-index-returned"""Numeral registry index of the protocol. Raises: IntError: This protocol doesn't support :meth:`__index__`. """raiseIntError(f'{cls.__name__!r} object cannot be interpreted as an integer')
[docs]def_decode_next_layer(self,dict_:'_PT',proto:'Optional[int]'=None,length:'Optional[int]'=None,*,packet:'Optional[dict[str, Any]]'=None)->'NoReturn':"""Decode next layer protocol. Raises: UnsupportedCall: This protocol doesn't support :meth:`_decode_next_layer`. """raiseUnsupportedCall(f"'{self.__class__.__name__}' object has no attribute '_decode_next_layer'")
[docs]def_import_next_layer(self,proto:'int',length:'Optional[int]'=None,*,# type: ignore[override]packet:'Optional[dict[str, Any]]'=None)->'NoReturn':"""Import next layer extractor. Raises: UnsupportedCall: This protocol doesn't support :meth:`_import_next_layer`. """raiseUnsupportedCall(f"'{self.__class__.__name__}' object has no attribute '_import_next_layer'")