[docs]defregister_protocol(protocol:'Type[Protocol]')->'None':"""Registered protocol class. The protocol class must be a subclass of :class:`~pcapkit.protocols.protocol.Protocol`, and will be registered to the :data:`pcapkit.protocols.__proto__` registry. Args: protocol: Protocol class. """ifnotissubclass(protocol,Protocol):raiseRegistryError(f'protocol must be a Protocol subclass, not {protocol!r}')protocol_registry[protocol.__name__.upper()]=protocollogger.info('registered protocol: %s',protocol.__name__)
[docs]defregister_linktype(code:'LinkType',module:'str | ModuleDescriptor[Protocol] | Type[Protocol]',class_:'str'=NULL)->'None':r"""Register a new protocol class. Notes: The full qualified class name of the new protocol class should be as ``{module}.{class_}``. The function will register the given protocol class to the following registries: - :data:`pcapkit.protocols.misc.pcap.frame.Frame.__proto__` - :data:`pcapkit.protocols.misc.pcapng.PCAPNG.__proto__` Arguments: code: protocol code as in :class:`~pcapkit.const.reg.linktype.LinkType` module: module name or module descriptor or a :class:`~pcapkit.protocols.protocol.Protocol` subclass class\_: class name See Also: * :func:`pcapkit.foundation.registry.protocols.register_pcap` * :func:`pcapkit.foundation.registry.protocols.register_pcapng` """ifisinstance(module,str):module=cast('ModuleDescriptor[Protocol]',ModuleDescriptor(module,class_))Frame.register(code,module)PCAPNG.register(code,module)logger.info('registered linktype protocol: %s',code.name)# register protocol to protocol registryifisinstance(module,ModuleDescriptor):module=module.klassregister_protocol(module)
[docs]defregister_pcap(code:'LinkType',module:'str | ModuleDescriptor[Protocol] | Type[Protocol]',class_:'str'=NULL)->'None':r"""Register a new protocol class. Notes: The full qualified class name of the new protocol class should be as ``{module}.{class_}``. The function will register the given protocol class to the :data:`pcapkit.protocols.misc.pcap.frame.Frame.__proto__` registry. Arguments: code: protocol code as in :class:`~pcapkit.const.reg.linktype.LinkType` module: module name or module descriptor or a :class:`~pcapkit.protocols.protocol.Protocol` subclass class\_: class name """ifisinstance(module,str):module=cast('ModuleDescriptor[Protocol]',ModuleDescriptor(module,class_))Frame.register(code,module)logger.info('registered PCAP linktype protocol: %s',code.name)# register protocol to protocol registryifisinstance(module,ModuleDescriptor):module=module.klassregister_protocol(module)
[docs]defregister_pcapng(code:'LinkType',module:'str | ModuleDescriptor[Protocol] | Type[Protocol]',class_:'str'=NULL)->'None':r"""Register a new protocol class. Notes: The full qualified class name of the new protocol class should be as ``{module}.{class_}``. The function will register the given protocol class to the :data:`pcapkit.protocols.misc.pcapng.PCAPNG.__proto__` registry. Arguments: code: protocol code as in :class:`~pcapkit.const.reg.linktype.LinkType` module: module name or module descriptor or a :class:`~pcapkit.protocols.protocol.Protocol` subclass class\_: class name """ifisinstance(module,str):module=cast('ModuleDescriptor[Protocol]',ModuleDescriptor(module,class_))PCAPNG.register(code,module)logger.info('registered PCAP-NG linktype protocol: %s',code.name)# register protocol to protocol registryifisinstance(module,ModuleDescriptor):module=module.klassregister_protocol(module)
################################################################################ Link Layer Registries###############################################################################@overloaddefregister_ethertype(code:'EtherType',module:'ModuleDescriptor[Protocol] | Type[Protocol]')->'None':...@overloaddefregister_ethertype(code:'EtherType',module:'str',class_:'str')->'None':...# NOTE: pcapkit.protocols.link.link.Link.__proto__
[docs]defregister_ethertype(code:'EtherType',module:'str | ModuleDescriptor[Protocol] | Type[Protocol]',class_:'str'=NULL)->'None':r"""Register a new protocol class. Notes: The full qualified class name of the new protocol class should be as ``{module}.{class_}``. The function will register the given protocol class to the :data:`pcapkit.protocols.link.link.Link.__proto__` registry. Arguments: code: protocol code as in :class:`~pcapkit.const.reg.ethertype.EtherType` module: module name or module descriptor or a :class:`~pcapkit.protocols.protocol.Protocol` subclass class\_: class name """ifisinstance(module,str):module=cast('ModuleDescriptor[Protocol]',ModuleDescriptor(module,class_))Link.register(code,module)logger.info('registered ethertype protocol: %s',code.name)# register protocol to protocol registryifisinstance(module,ModuleDescriptor):module=module.klassregister_protocol(module)
################################################################################ Internet Layer Registries###############################################################################@overloaddefregister_transtype(code:'TransType',module:'ModuleDescriptor[Protocol] | Type[Protocol]')->'None':...@overloaddefregister_transtype(code:'TransType',module:'str',class_:'str')->'None':...# NOTE: pcapkit.protocols.internet.internet.Internet.__proto__
[docs]defregister_transtype(code:'TransType',module:'str | ModuleDescriptor[Protocol] | Type[Protocol]',class_:'str'=NULL)->'None':r"""Register a new protocol class. Notes: The full qualified class name of the new protocol class should be as ``{module}.{class_}``. The function will register the given protocol class to the :data:`pcapkit.protocols.internet.internet.Internet.__proto__` registry. Arguments: code: protocol code as in :class:`~pcapkit.const.reg.transtype.TransType` module: module name or module descriptor or a :class:`~pcapkit.protocols.protocol.Protocol` subclass class\_: class name """ifisinstance(module,str):module=cast('ModuleDescriptor[Protocol]',ModuleDescriptor(module,class_))Internet.register(code,module)logger.info('registered transtype protocol: %s',code.name)# register protocol to protocol registryifisinstance(module,ModuleDescriptor):module=module.klassregister_protocol(module)
# NOTE: pcapkit.protocols.internet.internet.IPv4
[docs]defregister_ipv4_option(code:'IPv4_OptionNumber',meth:'str | tuple[IPv4_OptionParser, IPv4_OptionConstructor]',*,schema:'Optional[Type[Schema_IPv4_Option]]'=None)->'None':"""Register an option parser. The function will register the given option parser to the :data:`pcapkit.protocols.internet.internet.IPv4` internal registry. Args: code: :class:`IPv4 <pcapkit.protocols.internet.ipv4.IPv4>` option code as in :class:`~pcapkit.const.ipv4.option_number.OptionNumber`. meth: Method name or callable to parse and/or construct the option. schema: :class:`~pcapkit.protocols.schema.schema.Schema` class for the option. It should be a subclass of :class:`pcapkit.protocols.schema.internet.ipv4.Option`. """ifisinstance(meth,str)andnothasattr(IPv4,f'_read_opt_{meth}'):raiseRegistryError('method must be a valid IPv4 option parser function')IPv4.register_option(code,meth)ifschemaisnotNone:Schema_IPv4_Option.register(code,schema)logger.info('registered IPv4 option parser: %s',code.name)
# NOTE: pcapkit.protocols.internet.hip.HIP
[docs]defregister_hip_parameter(code:'HIP_Parameter',meth:'str | tuple[HIP_ParameterParser, HIP_ParameterConstructor]',*,schema:'Optional[Type[Schema_HIP_Parameter]]'=None)->'None':"""Register a parameter parser. The function will register the given parameter parser to the :data:`pcapkit.protocols.internet.hip.HIP` internal registry. Args: code: :class:`~pcapkit.protocols.internet.hip.HIP` parameter code as in :class:`~pcapkit.const.hip.parameter.Parameter`. meth: Method name or callable to parse and/or construct the parameter. schema: :class:`~pcapkit.protocols.schema.schema.Schema` class for the parameter. It should be a subclass of :class:`pcapkit.protocols.schema.internet.hip.Parameter`. """ifisinstance(meth,str)andnothasattr(HIP,f'_read_param_{meth}'):raiseRegistryError('method must be a valid HIP parameter parser function')HIP.register_parameter(code,meth)ifschemaisnotNone:Schema_HIP_Parameter.register(code,schema)logger.info('registered HIP parameter parser: %s',code.name)
[docs]defregister_hopopt_option(code:'IPv6_Option',meth:'str | tuple[HOPOPT_OptionParser, HOPOPT_OptionConstructor]',*,schema:'Optional[Type[Schema_HOPOPT_Option]]'=None)->'None':"""Register an option parser. The function will register the given option parser to the :data:`pcapkit.protocols.internet.hopopt.HOPOPT.__option__` registry. Args: code: :class:`~pcapkit.protocols.internet.hopopt.HOPOPT` option code as in :class:`~pcapkit.const.ipv6.option.Option`. meth: Method name or callable to parse and/or construct the option. schema: :class:`~pcapkit.protocols.schema.schema.Schema` class for the option. It should be a subclass of :class:`pcapkit.protocols.schema.internet.hopopt.Option`. """ifisinstance(meth,str)andnothasattr(HOPOPT,f'_read_opt_{meth}'):raiseRegistryError('method must be a valid HOPOPT option parser function')HOPOPT.register_option(code,meth)ifschemaisnotNone:Schema_HOPOPT_Option.register(code,schema)logger.info('registered HOPOPT option parser: %s',code.name)
[docs]defregister_ipv6_opts_option(code:'IPv6_Option',meth:'str | tuple[IPv6_Opts_OptionParser, IPv6_Opts_OptionConstructor]',*,schema:'Optional[Type[Schema_IPv6_Opts_Option]]'=None)->'None':"""Register an option parser. The function will register the given option parser to the :data:`pcapkit.protocols.internet.ipv6_opts.IPv6_Opts.__option__` registry. Args: code: :class:`IPv6-Opts <pcapkit.protocols.internet.ipv6_opts.IPv6_Opts>` option code as in :class:`~pcapkit.const.ipv6.option.Option`. meth: Method name or callable to parse and/or construct the option. schema: :class:`~pcapkit.protocols.schema.schema.Schema` class for the option. It should be a subclass of :class:`pcapkit.protocols.schema.internet.ipv6_opts.Option`. """ifisinstance(meth,str)andnothasattr(IPv6_Opts,f'_read_opt_{meth}'):raiseRegistryError('method must be a valid IPv6-Opts option parser function')IPv6_Opts.register_option(code,meth)ifschemaisnotNone:Schema_IPv6_Opts_Option.register(code,schema)logger.info('registered IPv6-Opts option parser: %s',code.name)
[docs]defregister_ipv6_route_routing(code:'IPv6_Routing',meth:'str | tuple[IPv6_Route_TypeParser, IPv6_Route_TypeConstructor]',*,schema:'Optional[Type[Schema_IPv6_Route_RoutingType]]'=None)->'None':"""Register a routing data parser. The function will register the given routing data parser to the :data:`pcapkit.protocols.internet.ipv6_route.IPv6_Route.__routing__` registry. Args: code: :class:`IPv6-Route <pcapkit.protocols.internet.ipv6_route.IPv6_Route>` data type code as in :class:`~pcapkit.const.ipv6.routing.Routing`. meth: Method name or callable to parse and/or construct the data. schema: :class:`~pcapkit.protocols.schema.schema.Schema` class for the routing data. It should be a subclass of :class:`pcapkit.protocols.schema.internet.ipv6_route.RoutingType`. """ifisinstance(meth,str)andnothasattr(IPv6_Route,f'_read_data_type_{meth}'):raiseRegistryError('method must be a valid IPv6-Route routing data parser function')IPv6_Route.register_routing(code,meth)ifschemaisnotNone:Schema_IPv6_Route_RoutingType.register(code,schema)logger.info('registered IPv6-Route routing data parser: %s',code.name)
[docs]defregister_mh_message(code:'MH_Packet',meth:'str | tuple[MH_PacketParser, MH_PacketConstructor]',*,schema:'Optional[Type[Schema_MH_Packet]]'=None)->'None':"""Register a MH message type parser. The function will register the given message type parser to the :data:`pcapkit.protocols.internet.mh.MH.__message__` registry. Args: code: :class:`~pcapkit.protocols.internet.mh.MH>` data type code as in :class:`~pcapkit.const.mh.packet.Packet`. meth: Method name or callable to parse and/or construct the data. schema: :class:`~pcapkit.protocols.schema.schema.Schema` class for the message type. It should be a subclass of :class:`pcapkit.protocols.schema.internet.mh.Packet`. """ifisinstance(meth,str)andnothasattr(MH,f'_read_msg_{meth}'):raiseRegistryError('method must be a valid MH message type parser function')MH.register_message(code,meth)ifschemaisnotNone:Schema_MH_Packet.register(code,schema)logger.info('registered MH message type parser: %s',code.name)
[docs]defregister_mh_option(code:'MH_Option',meth:'str | tuple[MH_OptionParser, MH_OptionConstructor]',*,schema:'Optional[Type[Schema_MH_Option]]'=None)->'None':"""Register a MH option parser. The function will register the given option parser to the :data:`pcapkit.protocols.internet.mh.MH.__option__` registry. Args: code: :class:`~pcapkit.protocols.internet.mh.MH>` data type code as in :class:`~pcapkit.const.mh.option.Option`. meth: Method name or callable to parse and/or construct the data. schema: :class:`~pcapkit.protocols.schema.schema.Schema` class for the message type. It should be a subclass of :class:`pcapkit.protocols.schema.internet.mh.Option`. """ifisinstance(meth,str)andnothasattr(MH,f'_read_opt_{meth}'):raiseRegistryError('method must be a valid MH option parser function')MH.register_option(code,meth)ifschemaisnotNone:Schema_MH_Option.register(code,schema)logger.info('registered MH option parser: %s',code.name)
[docs]defregister_mh_extension(code:'MH_CGAExtension',meth:'str | tuple[MH_ExtensionParser, MH_ExtensionConstructor]',schema:'Optional[Type[Schema_MH_CGAExtension]]'=None)->'None':"""Register a CGA extension parser. The function will register the given CGA extension to the :data:`pcapkit.protocols.internet.mh.MH.__extension__` registry. Args: code: :class:`~pcapkit.protocols.internet.mh.MH>` data type code as in :class:`~pcapkit.const.mh.cga_extension.CGAExtension`. meth: Method name or callable to parse and/or construct the data. schema: :class:`~pcapkit.protocols.schema.schema.Schema` class for the message type. It should be a subclass of :class:`pcapkit.protocols.schema.internet.mh.CGAExtension`. """ifisinstance(meth,str)andnothasattr(MH,f'_read_ext_{meth}'):raiseRegistryError('method must be a valid MH CGA extension function')MH.register_extension(code,meth)ifschemaisnotNone:Schema_MH_CGAExtension.register(code,schema)logger.info('registered MH CGA extension: %s',code.name)
[docs]defregister_apptype(code:'int | Enum_AppType',module:'str | ModuleDescriptor[Protocol] | Type[Protocol]',class_:'str'=NULL,*,proto:'TransportProtocol | str'=NULL)->'None':r"""Register a new protocol class. Notes: The full qualified class name of the new protocol class should be as ``{module}.{class_}``. The function will register the given protocol class to the :data:`pcapkit.protocols.transport.tcp.TCP.__proto__` and/or :data:`pcapkit.protocols.transport.udp.UDP.__proto__` registry. Arguments: code: port number module: module name or module descriptor or a :class:`~pcapkit.protocols.protocol.Protocol` subclass class\_: class name proto: protocol name (must be a valid transport protocol) See Also: * :func:`pcapkit.foundation.registry.register_tcp` * :func:`pcapkit.foundation.registry.register_udp` """ifisinstance(code,Enum_AppType):ifprotoisNULL:proto=code.protocode=code.portifisinstance(module,str):module=cast('ModuleDescriptor[Protocol]',ModuleDescriptor(module,class_))_reg=Falseifisinstance(proto,str):proto=TransportProtocol.get(proto.lower())fortest,clsincast('dict[TransportProtocol, Type[Protocol]]',{TransportProtocol.tcp:TCP,TransportProtocol.udp:UDP,}).items():iftestnotinproto:continuecls.register(code,module)logger.info('registered %s port: %s',test.name,code)_reg=Trueifnot_reg:raiseRegistryError(f'unknown transport protocol: {proto.name}')# register protocol to protocol registryifisinstance(module,ModuleDescriptor):module=module.klassregister_protocol(module)
[docs]defregister_tcp(code:'int | Enum_AppType',module:'str | ModuleDescriptor[Protocol] | Type[Protocol]',class_:'str'=NULL)->'None':r"""Register a new protocol class. Notes: The full qualified class name of the new protocol class should be as ``{module}.{class_}``. The function will register the given protocol class to the :data:`pcapkit.protocols.transport.tcp.TCP.__proto__` registry. Arguments: code: port number module: module name or module descriptor or a :class:`~pcapkit.protocols.protocol.Protocol` subclass class\_: class name """ifisinstance(code,Enum_AppType):code=code.portifisinstance(module,str):module=cast('ModuleDescriptor[Protocol]',ModuleDescriptor(module,class_))TCP.register(code,module)logger.info('registered TCP port: %s',code)# register protocol to protocol registryifisinstance(module,ModuleDescriptor):module=module.klassregister_protocol(module)
[docs]defregister_tcp_option(code:'TCP_Option',meth:'str | tuple[TCP_OptionParser, TCP_OptionConstructor]',*,schema:'Optional[Type[Schema_TCP_Option]]'=None)->'None':"""Register an option parser. The function will register the given option parser to the :data:`pcapkit.protocols.transport.tcp.TCP.__option__` registry. Args: code: :class:`~pcapkit.protocols.transport.tcp.TCP` option code as in :class:`~pcapkit.const.tcp.option.Option`. meth: Method name or callable to parse and/or construct the option. schema: :class:`~pcapkit.protocols.schema.schema.Schema` class for the option. It should be a subclass of :class:`pcapkit.protocols.schema.transport.tcp.Option`. """ifisinstance(meth,str)andnothasattr(TCP,f'_read_mode_{meth}'):raiseRegistryError('method must be a TCP option parser function')TCP.register_option(code,meth)ifschemaisnotNone:Schema_TCP_Option.register(code,schema)logger.info('registered TCP option parser: %s',code.name)
[docs]defregister_tcp_mp_option(code:'TCP_MPTCPOption',meth:'str | tuple[TCP_MPOptionParser, TCP_MPOptionConstructor]',*,schema:'Optional[Type[Schema_TCP_MPTCP]]'=None)->'None':"""Register an MPTCP option parser. The function will register the given option parser to the :data:`pcapkit.protocols.transport.tcp.TCP.__mp_option__` registry. Args: code: Multipath :class:`~pcapkit.protocols.transport.tcp.TCP` option code as in :class:`~pcapkit.const.tcp.mp_tcp_option.MPTCPOption`. meth: Method name or callable to parse and/or construct the option. schema: :class:`~pcapkit.protocols.schema.schema.Schema` class for the option. It should be a subclass of :class:`pcapkit.protocols.schema.transport.tcp.MPTCP`. """ifisinstance(meth,str)andnothasattr(TCP,f'_read_mptcp_{meth}'):raiseRegistryError('method must be a MPTCP option parser function')TCP.register_mp_option(code,meth)ifschemaisnotNone:Schema_TCP_MPTCP.register(code,schema)logger.info('registered MPTCP option parser: %s',code.name)
[docs]defregister_udp(code:'int | Enum_AppType',module:'str | ModuleDescriptor[Protocol] | Type[Protocol]',class_:'str'=NULL)->'None':r"""Register a new protocol class. Notes: The full qualified class name of the new protocol class should be as ``{module}.{class_}``. The function will register the given protocol class to the :data:`pcapkit.protocols.transport.udp.UDP.__proto__` registry. Arguments: code: port number module: module name or module descriptor or a :class:`~pcapkit.protocols.protocol.Protocol` subclass class\_: class name """ifisinstance(code,Enum_AppType):code=code.portifisinstance(module,str):module=cast('ModuleDescriptor[Protocol]',ModuleDescriptor(module,class_))UDP.register(code,module)logger.info('registered UDP port: %s',code)# register protocol to protocol registryifisinstance(module,ModuleDescriptor):module=module.klassregister_protocol(module)
[docs]defregister_http_frame(code:'HTTP_Frame',meth:'str | tuple[HTTP_FrameParser, HTTP_FrameConstructor]',*,schema:'Optional[Type[Schema_HTTP_FrameType]]'=None)->'None':"""Registered a frame parser. The function will register the given frame parser to the :data:`pcapkit.protocols.application.httpv2.HTTP.__frame__` registry. Args: code: :class:`HTTP/2 <pcapkit.protocols.application.httpv2.HTTP>` frame type code as in :class:`~pcapkit.const.http.frame.Frame`. meth: Method name or callable to parse and/or construct the frame. schema: :class:`~pcapkit.protocols.schema.schema.Schema` class for the frame. It should be a subclass of :class:`pcapkit.protocols.schema.application.httpv2.FrameType`. """ifisinstance(meth,str)andnothasattr(HTTPv2,f'_read_http_{meth}'):raiseRegistryError('method must be a frame parser function')HTTPv2.register_frame(code,meth)ifschemaisnotNone:Schema_HTTP_FrameType.register(code,schema)logger.info('registered HTTP/2 frame parser: %s',code.name)
[docs]defregister_pcapng_block(code:'PCAPNG_BlockType',meth:'str | tuple[PCAPNG_BlockParser, PCAPNG_BlockConstructor]',*,schema:'Optional[Type[Schema_PCAPNG_BlockType]]'=None)->'None':"""Registered a block parser. The function will register the given block parser to the :data:`pcapkit.protocols.misc.pcapng.PCAPNG.__block__` registry. Args: code: :class:`HTTP/2 <pcapkit.protocols.misc.pcapng.PCAPNG>` block type code as in :class:`~pcapkit.const.pcapng.block_type.BlockType`. meth: Method name or callable to parse and/or construct the block. schema: :class:`~pcapkit.protocols.schema.schema.Schema` class for the block. It should be a subclass of :class:`pcapkit.protocols.schema.misc.pcapng.BlockType`. """ifisinstance(meth,str)andnothasattr(PCAPNG,f'_read_block_{meth}'):raiseRegistryError('method must be a block parser function')PCAPNG.register_block(code,meth)ifschemaisnotNone:Schema_PCAPNG_BlockType.register(code,schema)logger.info('registered PCAP-NG block parser: %s',code.name)
[docs]defregister_pcapng_option(code:'PCAPNG_OptionType',meth:'str | tuple[PCAPNG_OptionParser, PCAPNG_OptionConstructor]',*,schema:'Optional[Type[Schema_PCAPNG_Option]]'=None)->'None':"""Registered a option parser. The function will register the given option parser to the :data:`pcapkit.protocols.misc.pcapng.PCAPNG.__option__` registry. Args: code: :class:`PCAPNG <pcapkit.protocols.misc.pcapng.PCAPNG>` option type code as in :class:`~pcapkit.const.pcapng.option_type.OptionType`. meth: Method name or callable to parse and/or construct the option. schema: :class:`~pcapkit.protocols.schema.schema.Schema` class for the option. It should be a subclass of :class:`pcapkit.protocols.schema.misc.pcapng.Option`. """ifisinstance(meth,str)andnothasattr(PCAPNG,f'_read_option_{meth}'):raiseRegistryError('method must be a option parser function')PCAPNG.register_option(code,meth)ifschemaisnotNone:Schema_PCAPNG_Option.register(code,schema)logger.info('registered PCAP-NG option parser: %s',code.name)
[docs]defregister_pcapng_record(code:'PCAPNG_RecordType',meth:'str | tuple[PCAPNG_RecordParser, PCAPNG_RecordConstructor]',*,schema:'Optional[Type[Schema_PCAPNG_NameResolutionRecord]]'=None)->'None':"""Registered a name resolution record parser. The function will register the given name resolution record parser to the :data:`pcapkit.protocols.misc.pcapng.PCAPNG.__record__` registry. Args: code: :class:`PCAPNG <pcapkit.protocols.misc.pcapng.PCAPNG>` name resolution record type code as in :class:`~pcapkit.const.pcapng.record_type.RecordType`. meth: Method name or callable to parse and/or construct the name resolution record. schema: :class:`~pcapkit.protocols.schema.schema.Schema` class for the name resolution record. It should be a subclass of :class:`pcapkit.protocols.schema.misc.pcapng.NameResolutionRecord`. """ifisinstance(meth,str)andnothasattr(PCAPNG,f'_read_record_{meth}'):raiseRegistryError('method must be a name resolution record parser function')PCAPNG.register_record(code,meth)ifschemaisnotNone:Schema_PCAPNG_NameResolutionRecord.register(code,schema)logger.info('registered PCAP-NG name resolution record parser: %s',code.name)
[docs]defregister_pcapng_secrets(code:'PCAPNG_SecretsType',meth:'str | tuple[PCAPNG_SecretsParser, PCAPNG_SecretsConstructor]',*,schema:'Optional[Type[Schema_PCAPNG_DSBSecrets]]'=None)->'None':"""Registered a decryption secrets parser. The function will register the given decryption secrets parser to the :data:`pcapkit.protocols.misc.pcapng.PCAPNG.__secrets__` registry. Args: code: :class:`PCAPNG <pcapkit.protocols.misc.pcapng.PCAPNG>` decryption secrets type code as in :class:`~pcapkit.const.pcapng.secrets_type.SecretsType`. meth: Method name or callable to parse and/or construct the decryption secrets. schema: :class:`~pcapkit.protocols.schema.schema.Schema` class for the decryption secrets. It should be a subclass of :class:`pcapkit.protocols.schema.misc.pcapng.DSBSecrets`. """ifisinstance(meth,str)andnothasattr(PCAPNG,f'_read_secrets_{meth}'):raiseRegistryError('method must be a decryption secrets parser function')PCAPNG.register_secrets(code,meth)ifschemaisnotNone:Schema_PCAPNG_DSBSecrets.register(code,schema)logger.info('registered PCAP-NG decryption secrets parser: %s',code.name)