pypcapkit 1.3.3.post1__cp313-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pcapkit/__init__.py +126 -0
- pcapkit/__main__.py +138 -0
- pcapkit/all.py +136 -0
- pcapkit/const/__init__.py +81 -0
- pcapkit/const/arp/__init__.py +25 -0
- pcapkit/const/arp/hardware.py +181 -0
- pcapkit/const/arp/operation.py +131 -0
- pcapkit/const/ftp/__init__.py +25 -0
- pcapkit/const/ftp/command.py +309 -0
- pcapkit/const/ftp/return_code.py +304 -0
- pcapkit/const/hip/__init__.py +94 -0
- pcapkit/const/hip/certificate.py +77 -0
- pcapkit/const/hip/cipher.py +65 -0
- pcapkit/const/hip/di.py +59 -0
- pcapkit/const/hip/ecdsa_curve.py +59 -0
- pcapkit/const/hip/ecdsa_low_curve.py +56 -0
- pcapkit/const/hip/eddsa_curve.py +65 -0
- pcapkit/const/hip/esp_transform_suite.py +98 -0
- pcapkit/const/hip/group.py +86 -0
- pcapkit/const/hip/hi_algorithm.py +86 -0
- pcapkit/const/hip/hit_suite.py +68 -0
- pcapkit/const/hip/nat_traversal.py +62 -0
- pcapkit/const/hip/notify_message.py +200 -0
- pcapkit/const/hip/packet.py +89 -0
- pcapkit/const/hip/parameter.py +377 -0
- pcapkit/const/hip/registration.py +68 -0
- pcapkit/const/hip/registration_failure.py +84 -0
- pcapkit/const/hip/suite.py +71 -0
- pcapkit/const/hip/transport.py +59 -0
- pcapkit/const/http/__init__.py +39 -0
- pcapkit/const/http/error_code.py +95 -0
- pcapkit/const/http/frame.py +95 -0
- pcapkit/const/http/method.py +184 -0
- pcapkit/const/http/setting.py +96 -0
- pcapkit/const/http/status_code.py +294 -0
- pcapkit/const/ipv4/__init__.py +57 -0
- pcapkit/const/ipv4/classification_level.py +64 -0
- pcapkit/const/ipv4/option_class.py +55 -0
- pcapkit/const/ipv4/option_number.py +137 -0
- pcapkit/const/ipv4/protection_authority.py +63 -0
- pcapkit/const/ipv4/qs_function.py +51 -0
- pcapkit/const/ipv4/router_alert.py +251 -0
- pcapkit/const/ipv4/tos_del.py +51 -0
- pcapkit/const/ipv4/tos_ecn.py +55 -0
- pcapkit/const/ipv4/tos_pre.py +63 -0
- pcapkit/const/ipv4/tos_rel.py +51 -0
- pcapkit/const/ipv4/tos_thr.py +51 -0
- pcapkit/const/ipv4/ts_flag.py +53 -0
- pcapkit/const/ipv6/__init__.py +53 -0
- pcapkit/const/ipv6/extension_header.py +66 -0
- pcapkit/const/ipv6/option.py +137 -0
- pcapkit/const/ipv6/option_action.py +55 -0
- pcapkit/const/ipv6/qs_function.py +51 -0
- pcapkit/const/ipv6/router_alert.py +266 -0
- pcapkit/const/ipv6/routing.py +80 -0
- pcapkit/const/ipv6/seed_id.py +55 -0
- pcapkit/const/ipv6/smf_dpd_mode.py +51 -0
- pcapkit/const/ipv6/tagger_id.py +62 -0
- pcapkit/const/ipx/__init__.py +27 -0
- pcapkit/const/ipx/packet.py +72 -0
- pcapkit/const/ipx/socket.py +104 -0
- pcapkit/const/l2tp/__init__.py +21 -0
- pcapkit/const/l2tp/type.py +51 -0
- pcapkit/const/mh/__init__.py +204 -0
- pcapkit/const/mh/access_type.py +92 -0
- pcapkit/const/mh/ack_status_code.py +71 -0
- pcapkit/const/mh/ani_suboption.py +74 -0
- pcapkit/const/mh/auth_subtype.py +53 -0
- pcapkit/const/mh/binding_ack_flag.py +66 -0
- pcapkit/const/mh/binding_error.py +51 -0
- pcapkit/const/mh/binding_revocation.py +59 -0
- pcapkit/const/mh/binding_update_flag.py +81 -0
- pcapkit/const/mh/cga_extension.py +66 -0
- pcapkit/const/mh/cga_sec.py +57 -0
- pcapkit/const/mh/cga_type.py +68 -0
- pcapkit/const/mh/dhcp_support_mode.py +53 -0
- pcapkit/const/mh/dns_status_code.py +65 -0
- pcapkit/const/mh/dsmip6_tls_packet.py +62 -0
- pcapkit/const/mh/dsmipv6_home_address.py +74 -0
- pcapkit/const/mh/enumerating_algorithm.py +56 -0
- pcapkit/const/mh/fb_ack_status.py +62 -0
- pcapkit/const/mh/fb_action.py +71 -0
- pcapkit/const/mh/fb_indication_trigger.py +65 -0
- pcapkit/const/mh/fb_type.py +59 -0
- pcapkit/const/mh/flow_id_status.py +77 -0
- pcapkit/const/mh/flow_id_suboption.py +71 -0
- pcapkit/const/mh/handoff_type.py +71 -0
- pcapkit/const/mh/handover_ack_flag.py +54 -0
- pcapkit/const/mh/handover_ack_status.py +92 -0
- pcapkit/const/mh/handover_initiate_flag.py +57 -0
- pcapkit/const/mh/handover_initiate_status.py +62 -0
- pcapkit/const/mh/home_address_reply.py +71 -0
- pcapkit/const/mh/lla_code.py +63 -0
- pcapkit/const/mh/lma_mag_suboption.py +59 -0
- pcapkit/const/mh/mn_group_id.py +59 -0
- pcapkit/const/mh/mn_id_subtype.py +77 -0
- pcapkit/const/mh/operator_id.py +63 -0
- pcapkit/const/mh/option.py +260 -0
- pcapkit/const/mh/packet.py +119 -0
- pcapkit/const/mh/qos_attribute.py +89 -0
- pcapkit/const/mh/revocation_status_code.py +83 -0
- pcapkit/const/mh/revocation_trigger.py +86 -0
- pcapkit/const/mh/status_code.py +232 -0
- pcapkit/const/mh/traffic_selector.py +62 -0
- pcapkit/const/mh/upa_status.py +71 -0
- pcapkit/const/mh/upn_reason.py +80 -0
- pcapkit/const/ospf/__init__.py +27 -0
- pcapkit/const/ospf/authentication.py +65 -0
- pcapkit/const/ospf/packet.py +71 -0
- pcapkit/const/pcapng/__init__.py +51 -0
- pcapkit/const/pcapng/block_type.py +152 -0
- pcapkit/const/pcapng/filter_type.py +48 -0
- pcapkit/const/pcapng/hash_algorithm.py +59 -0
- pcapkit/const/pcapng/option_type.py +233 -0
- pcapkit/const/pcapng/record_type.py +57 -0
- pcapkit/const/pcapng/secrets_type.py +56 -0
- pcapkit/const/pcapng/verdict_type.py +53 -0
- pcapkit/const/reg/__init__.py +34 -0
- pcapkit/const/reg/apptype.py +32702 -0
- pcapkit/const/reg/ethertype.py +714 -0
- pcapkit/const/reg/linktype.py +902 -0
- pcapkit/const/reg/transtype.py +523 -0
- pcapkit/const/tcp/__init__.py +35 -0
- pcapkit/const/tcp/checksum.py +55 -0
- pcapkit/const/tcp/flags.py +73 -0
- pcapkit/const/tcp/mp_tcp_option.py +80 -0
- pcapkit/const/tcp/option.py +198 -0
- pcapkit/const/vlan/__init__.py +23 -0
- pcapkit/const/vlan/priority_level.py +71 -0
- pcapkit/corekit/__init__.py +59 -0
- pcapkit/corekit/fields/__init__.py +45 -0
- pcapkit/corekit/fields/collections.py +282 -0
- pcapkit/corekit/fields/field.py +269 -0
- pcapkit/corekit/fields/ipaddress.py +274 -0
- pcapkit/corekit/fields/misc.py +722 -0
- pcapkit/corekit/fields/numbers.py +375 -0
- pcapkit/corekit/fields/strings.py +245 -0
- pcapkit/corekit/infoclass.py +394 -0
- pcapkit/corekit/io.py +506 -0
- pcapkit/corekit/module.py +39 -0
- pcapkit/corekit/multidict.py +626 -0
- pcapkit/corekit/protochain.py +263 -0
- pcapkit/corekit/version.py +33 -0
- pcapkit/dumpkit/__init__.py +15 -0
- pcapkit/dumpkit/common.py +199 -0
- pcapkit/dumpkit/null.py +77 -0
- pcapkit/dumpkit/pcap.py +144 -0
- pcapkit/foundation/__init__.py +45 -0
- pcapkit/foundation/engines/__init__.py +36 -0
- pcapkit/foundation/engines/dpkt.py +230 -0
- pcapkit/foundation/engines/engine.py +194 -0
- pcapkit/foundation/engines/pcap.py +188 -0
- pcapkit/foundation/engines/pcapng.py +310 -0
- pcapkit/foundation/engines/pyshark.py +166 -0
- pcapkit/foundation/engines/scapy.py +161 -0
- pcapkit/foundation/extraction.py +915 -0
- pcapkit/foundation/reassembly/__init__.py +49 -0
- pcapkit/foundation/reassembly/data/__init__.py +48 -0
- pcapkit/foundation/reassembly/data/ip.py +117 -0
- pcapkit/foundation/reassembly/data/tcp.py +145 -0
- pcapkit/foundation/reassembly/ip.py +192 -0
- pcapkit/foundation/reassembly/ipv4.py +50 -0
- pcapkit/foundation/reassembly/ipv6.py +50 -0
- pcapkit/foundation/reassembly/reassembly.py +389 -0
- pcapkit/foundation/reassembly/tcp.py +249 -0
- pcapkit/foundation/registry/__init__.py +41 -0
- pcapkit/foundation/registry/foundation.py +327 -0
- pcapkit/foundation/registry/protocols.py +885 -0
- pcapkit/foundation/traceflow/__init__.py +44 -0
- pcapkit/foundation/traceflow/data/__init__.py +30 -0
- pcapkit/foundation/traceflow/data/tcp.py +105 -0
- pcapkit/foundation/traceflow/tcp.py +159 -0
- pcapkit/foundation/traceflow/traceflow.py +390 -0
- pcapkit/interface/__init__.py +22 -0
- pcapkit/interface/core.py +185 -0
- pcapkit/interface/misc.py +120 -0
- pcapkit/protocols/__init__.py +85 -0
- pcapkit/protocols/application/NotImplemented/bgp.py +0 -0
- pcapkit/protocols/application/NotImplemented/dhcp.py +0 -0
- pcapkit/protocols/application/NotImplemented/dhcpv6.py +0 -0
- pcapkit/protocols/application/NotImplemented/dns.py +0 -0
- pcapkit/protocols/application/NotImplemented/imap.py +0 -0
- pcapkit/protocols/application/NotImplemented/ldap.py +0 -0
- pcapkit/protocols/application/NotImplemented/mqtt.py +0 -0
- pcapkit/protocols/application/NotImplemented/nntp.py +0 -0
- pcapkit/protocols/application/NotImplemented/ntp.py +0 -0
- pcapkit/protocols/application/NotImplemented/onc_rpc.py +0 -0
- pcapkit/protocols/application/NotImplemented/pop.py +0 -0
- pcapkit/protocols/application/NotImplemented/rip.py +0 -0
- pcapkit/protocols/application/NotImplemented/rtp.py +0 -0
- pcapkit/protocols/application/NotImplemented/sip.py +0 -0
- pcapkit/protocols/application/NotImplemented/smtp.py +0 -0
- pcapkit/protocols/application/NotImplemented/snmp.py +0 -0
- pcapkit/protocols/application/NotImplemented/ssh.py +0 -0
- pcapkit/protocols/application/NotImplemented/telnet.py +0 -0
- pcapkit/protocols/application/NotImplemented/tls.py +0 -0
- pcapkit/protocols/application/NotImplemented/xmpp.py +0 -0
- pcapkit/protocols/application/__init__.py +34 -0
- pcapkit/protocols/application/application.py +114 -0
- pcapkit/protocols/application/ftp.py +206 -0
- pcapkit/protocols/application/http.py +176 -0
- pcapkit/protocols/application/httpv1.py +320 -0
- pcapkit/protocols/application/httpv2.py +1255 -0
- pcapkit/protocols/data/__init__.py +192 -0
- pcapkit/protocols/data/application/__init__.py +57 -0
- pcapkit/protocols/data/application/ftp.py +59 -0
- pcapkit/protocols/data/application/httpv1.py +79 -0
- pcapkit/protocols/data/application/httpv2.py +293 -0
- pcapkit/protocols/data/data.py +25 -0
- pcapkit/protocols/data/internet/__init__.py +298 -0
- pcapkit/protocols/data/internet/ah.py +31 -0
- pcapkit/protocols/data/internet/hip.py +804 -0
- pcapkit/protocols/data/internet/hopopt.py +351 -0
- pcapkit/protocols/data/internet/ipv4.py +369 -0
- pcapkit/protocols/data/internet/ipv6.py +67 -0
- pcapkit/protocols/data/internet/ipv6_frag.py +29 -0
- pcapkit/protocols/data/internet/ipv6_opts.py +368 -0
- pcapkit/protocols/data/internet/ipv6_route.py +86 -0
- pcapkit/protocols/data/internet/ipx.py +56 -0
- pcapkit/protocols/data/internet/mh.py +509 -0
- pcapkit/protocols/data/link/__init__.py +33 -0
- pcapkit/protocols/data/link/arp.py +74 -0
- pcapkit/protocols/data/link/ethernet.py +28 -0
- pcapkit/protocols/data/link/l2tp.py +63 -0
- pcapkit/protocols/data/link/ospf.py +58 -0
- pcapkit/protocols/data/link/vlan.py +42 -0
- pcapkit/protocols/data/misc/__init__.py +109 -0
- pcapkit/protocols/data/misc/null.py +18 -0
- pcapkit/protocols/data/misc/pcap/__init__.py +18 -0
- pcapkit/protocols/data/misc/pcap/frame.py +56 -0
- pcapkit/protocols/data/misc/pcap/header.py +53 -0
- pcapkit/protocols/data/misc/pcapng.py +925 -0
- pcapkit/protocols/data/misc/raw.py +25 -0
- pcapkit/protocols/data/protocol.py +32 -0
- pcapkit/protocols/data/transport/__init__.py +71 -0
- pcapkit/protocols/data/transport/tcp.py +555 -0
- pcapkit/protocols/data/transport/udp.py +29 -0
- pcapkit/protocols/internet/NotImplemented/ecn.py +0 -0
- pcapkit/protocols/internet/NotImplemented/esp.py +97 -0
- pcapkit/protocols/internet/NotImplemented/icmp.py +0 -0
- pcapkit/protocols/internet/NotImplemented/icmpv6.py +0 -0
- pcapkit/protocols/internet/NotImplemented/igmp.py +0 -0
- pcapkit/protocols/internet/NotImplemented/shim6.py +0 -0
- pcapkit/protocols/internet/__init__.py +43 -0
- pcapkit/protocols/internet/ah.py +275 -0
- pcapkit/protocols/internet/hip.py +4727 -0
- pcapkit/protocols/internet/hopopt.py +1879 -0
- pcapkit/protocols/internet/internet.py +240 -0
- pcapkit/protocols/internet/ip.py +51 -0
- pcapkit/protocols/internet/ipsec.py +50 -0
- pcapkit/protocols/internet/ipv4.py +1782 -0
- pcapkit/protocols/internet/ipv6.py +361 -0
- pcapkit/protocols/internet/ipv6_frag.py +258 -0
- pcapkit/protocols/internet/ipv6_opts.py +1890 -0
- pcapkit/protocols/internet/ipv6_route.py +710 -0
- pcapkit/protocols/internet/ipx.py +230 -0
- pcapkit/protocols/internet/mh.py +2764 -0
- pcapkit/protocols/link/NotImplemented/dsl.py +0 -0
- pcapkit/protocols/link/NotImplemented/eapol.py +1 -0
- pcapkit/protocols/link/NotImplemented/fddi.py +0 -0
- pcapkit/protocols/link/NotImplemented/isdn.py +0 -0
- pcapkit/protocols/link/NotImplemented/ndp.py +0 -0
- pcapkit/protocols/link/NotImplemented/ppp.py +0 -0
- pcapkit/protocols/link/__init__.py +35 -0
- pcapkit/protocols/link/arp.py +421 -0
- pcapkit/protocols/link/ethernet.py +248 -0
- pcapkit/protocols/link/l2tp.py +267 -0
- pcapkit/protocols/link/link.py +140 -0
- pcapkit/protocols/link/ospf.py +342 -0
- pcapkit/protocols/link/rarp.py +82 -0
- pcapkit/protocols/link/vlan.py +225 -0
- pcapkit/protocols/misc/__init__.py +37 -0
- pcapkit/protocols/misc/null.py +129 -0
- pcapkit/protocols/misc/pcap/__init__.py +17 -0
- pcapkit/protocols/misc/pcap/frame.py +478 -0
- pcapkit/protocols/misc/pcap/header.py +358 -0
- pcapkit/protocols/misc/pcapng.py +5520 -0
- pcapkit/protocols/misc/raw.py +180 -0
- pcapkit/protocols/protocol.py +1216 -0
- pcapkit/protocols/schema/__init__.py +140 -0
- pcapkit/protocols/schema/application/__init__.py +40 -0
- pcapkit/protocols/schema/application/ftp.py +21 -0
- pcapkit/protocols/schema/application/httpv1.py +21 -0
- pcapkit/protocols/schema/application/httpv2.py +384 -0
- pcapkit/protocols/schema/internet/__init__.py +294 -0
- pcapkit/protocols/schema/internet/ah.py +40 -0
- pcapkit/protocols/schema/internet/hip.py +1184 -0
- pcapkit/protocols/schema/internet/hopopt.py +679 -0
- pcapkit/protocols/schema/internet/ipv4.py +576 -0
- pcapkit/protocols/schema/internet/ipv6.py +63 -0
- pcapkit/protocols/schema/internet/ipv6_frag.py +48 -0
- pcapkit/protocols/schema/internet/ipv6_opts.py +680 -0
- pcapkit/protocols/schema/internet/ipv6_route.py +198 -0
- pcapkit/protocols/schema/internet/ipx.py +40 -0
- pcapkit/protocols/schema/internet/mh.py +718 -0
- pcapkit/protocols/schema/link/__init__.py +19 -0
- pcapkit/protocols/schema/link/arp.py +39 -0
- pcapkit/protocols/schema/link/ethernet.py +51 -0
- pcapkit/protocols/schema/link/l2tp.py +88 -0
- pcapkit/protocols/schema/link/ospf.py +90 -0
- pcapkit/protocols/schema/link/vlan.py +69 -0
- pcapkit/protocols/schema/misc/__init__.py +108 -0
- pcapkit/protocols/schema/misc/null.py +18 -0
- pcapkit/protocols/schema/misc/pcap/__init__.py +10 -0
- pcapkit/protocols/schema/misc/pcap/frame.py +51 -0
- pcapkit/protocols/schema/misc/pcap/header.py +63 -0
- pcapkit/protocols/schema/misc/pcapng.py +1689 -0
- pcapkit/protocols/schema/misc/raw.py +24 -0
- pcapkit/protocols/schema/schema.py +809 -0
- pcapkit/protocols/schema/transport/__init__.py +69 -0
- pcapkit/protocols/schema/transport/tcp.py +928 -0
- pcapkit/protocols/schema/transport/udp.py +90 -0
- pcapkit/protocols/transport/NotImplemented/dccp.py +0 -0
- pcapkit/protocols/transport/NotImplemented/rsvp.py +0 -0
- pcapkit/protocols/transport/NotImplemented/sctp.py +0 -0
- pcapkit/protocols/transport/__init__.py +27 -0
- pcapkit/protocols/transport/tcp.py +3025 -0
- pcapkit/protocols/transport/transport.py +158 -0
- pcapkit/protocols/transport/udp.py +214 -0
- pcapkit/py.typed +0 -0
- pcapkit/toolkit/__init__.py +57 -0
- pcapkit/toolkit/dpkt.py +306 -0
- pcapkit/toolkit/pcap.py +212 -0
- pcapkit/toolkit/pcapng.py +251 -0
- pcapkit/toolkit/pyshark.py +99 -0
- pcapkit/toolkit/scapy.py +297 -0
- pcapkit/utilities/__init__.py +20 -0
- pcapkit/utilities/compat.py +196 -0
- pcapkit/utilities/decorators.py +192 -0
- pcapkit/utilities/exceptions.py +365 -0
- pcapkit/utilities/logging.py +55 -0
- pcapkit/utilities/warnings.py +185 -0
- pcapkit/vendor/__init__.py +105 -0
- pcapkit/vendor/__main__.py +92 -0
- pcapkit/vendor/arp/__init__.py +27 -0
- pcapkit/vendor/arp/hardware.py +29 -0
- pcapkit/vendor/arp/operation.py +29 -0
- pcapkit/vendor/default.py +474 -0
- pcapkit/vendor/ftp/__init__.py +27 -0
- pcapkit/vendor/ftp/command.py +244 -0
- pcapkit/vendor/ftp/return_code.py +256 -0
- pcapkit/vendor/hip/__init__.py +94 -0
- pcapkit/vendor/hip/certificate.py +29 -0
- pcapkit/vendor/hip/cipher.py +29 -0
- pcapkit/vendor/hip/di.py +29 -0
- pcapkit/vendor/hip/ecdsa_curve.py +29 -0
- pcapkit/vendor/hip/ecdsa_low_curve.py +29 -0
- pcapkit/vendor/hip/eddsa_curve.py +85 -0
- pcapkit/vendor/hip/esp_transform_suite.py +29 -0
- pcapkit/vendor/hip/group.py +87 -0
- pcapkit/vendor/hip/hi_algorithm.py +29 -0
- pcapkit/vendor/hip/hit_suite.py +29 -0
- pcapkit/vendor/hip/nat_traversal.py +29 -0
- pcapkit/vendor/hip/notify_message.py +29 -0
- pcapkit/vendor/hip/packet.py +88 -0
- pcapkit/vendor/hip/parameter.py +88 -0
- pcapkit/vendor/hip/registration.py +29 -0
- pcapkit/vendor/hip/registration_failure.py +29 -0
- pcapkit/vendor/hip/suite.py +29 -0
- pcapkit/vendor/hip/transport.py +29 -0
- pcapkit/vendor/http/__init__.py +39 -0
- pcapkit/vendor/http/error_code.py +95 -0
- pcapkit/vendor/http/frame.py +91 -0
- pcapkit/vendor/http/method.py +167 -0
- pcapkit/vendor/http/setting.py +93 -0
- pcapkit/vendor/http/status_code.py +185 -0
- pcapkit/vendor/ipv4/__init__.py +57 -0
- pcapkit/vendor/ipv4/classification_level.py +91 -0
- pcapkit/vendor/ipv4/option_class.py +80 -0
- pcapkit/vendor/ipv4/option_number.py +105 -0
- pcapkit/vendor/ipv4/protection_authority.py +84 -0
- pcapkit/vendor/ipv4/qs_function.py +78 -0
- pcapkit/vendor/ipv4/router_alert.py +93 -0
- pcapkit/vendor/ipv4/tos_del.py +78 -0
- pcapkit/vendor/ipv4/tos_ecn.py +95 -0
- pcapkit/vendor/ipv4/tos_pre.py +84 -0
- pcapkit/vendor/ipv4/tos_rel.py +78 -0
- pcapkit/vendor/ipv4/tos_thr.py +77 -0
- pcapkit/vendor/ipv4/ts_flag.py +79 -0
- pcapkit/vendor/ipv6/__init__.py +53 -0
- pcapkit/vendor/ipv6/extension_header.py +171 -0
- pcapkit/vendor/ipv6/option.py +104 -0
- pcapkit/vendor/ipv6/option_action.py +90 -0
- pcapkit/vendor/ipv6/qs_function.py +78 -0
- pcapkit/vendor/ipv6/router_alert.py +93 -0
- pcapkit/vendor/ipv6/routing.py +87 -0
- pcapkit/vendor/ipv6/seed_id.py +81 -0
- pcapkit/vendor/ipv6/smf_dpd_mode.py +78 -0
- pcapkit/vendor/ipv6/tagger_id.py +81 -0
- pcapkit/vendor/ipx/__init__.py +37 -0
- pcapkit/vendor/ipx/packet.py +123 -0
- pcapkit/vendor/ipx/socket.py +125 -0
- pcapkit/vendor/l2tp/__init__.py +21 -0
- pcapkit/vendor/l2tp/type.py +78 -0
- pcapkit/vendor/mh/__init__.py +204 -0
- pcapkit/vendor/mh/access_type.py +87 -0
- pcapkit/vendor/mh/ack_status_code.py +88 -0
- pcapkit/vendor/mh/ani_suboption.py +88 -0
- pcapkit/vendor/mh/auth_subtype.py +83 -0
- pcapkit/vendor/mh/binding_ack_flag.py +148 -0
- pcapkit/vendor/mh/binding_error.py +78 -0
- pcapkit/vendor/mh/binding_revocation.py +87 -0
- pcapkit/vendor/mh/binding_update_flag.py +147 -0
- pcapkit/vendor/mh/cga_extension.py +91 -0
- pcapkit/vendor/mh/cga_sec.py +91 -0
- pcapkit/vendor/mh/cga_type.py +74 -0
- pcapkit/vendor/mh/dhcp_support_mode.py +77 -0
- pcapkit/vendor/mh/dns_status_code.py +87 -0
- pcapkit/vendor/mh/dsmip6_tls_packet.py +87 -0
- pcapkit/vendor/mh/dsmipv6_home_address.py +87 -0
- pcapkit/vendor/mh/enumerating_algorithm.py +82 -0
- pcapkit/vendor/mh/fb_ack_status.py +87 -0
- pcapkit/vendor/mh/fb_action.py +88 -0
- pcapkit/vendor/mh/fb_indication_trigger.py +87 -0
- pcapkit/vendor/mh/fb_type.py +88 -0
- pcapkit/vendor/mh/flow_id_status.py +87 -0
- pcapkit/vendor/mh/flow_id_suboption.py +87 -0
- pcapkit/vendor/mh/handoff_type.py +87 -0
- pcapkit/vendor/mh/handover_ack_flag.py +143 -0
- pcapkit/vendor/mh/handover_ack_status.py +87 -0
- pcapkit/vendor/mh/handover_initiate_flag.py +143 -0
- pcapkit/vendor/mh/handover_initiate_status.py +87 -0
- pcapkit/vendor/mh/home_address_reply.py +87 -0
- pcapkit/vendor/mh/lla_code.py +97 -0
- pcapkit/vendor/mh/lma_mag_suboption.py +88 -0
- pcapkit/vendor/mh/mn_group_id.py +87 -0
- pcapkit/vendor/mh/mn_id_subtype.py +87 -0
- pcapkit/vendor/mh/operator_id.py +87 -0
- pcapkit/vendor/mh/option.py +83 -0
- pcapkit/vendor/mh/packet.py +82 -0
- pcapkit/vendor/mh/qos_attribute.py +87 -0
- pcapkit/vendor/mh/revocation_status_code.py +87 -0
- pcapkit/vendor/mh/revocation_trigger.py +87 -0
- pcapkit/vendor/mh/status_code.py +91 -0
- pcapkit/vendor/mh/traffic_selector.py +87 -0
- pcapkit/vendor/mh/upa_status.py +87 -0
- pcapkit/vendor/mh/upn_reason.py +87 -0
- pcapkit/vendor/ospf/__init__.py +27 -0
- pcapkit/vendor/ospf/authentication.py +29 -0
- pcapkit/vendor/ospf/packet.py +29 -0
- pcapkit/vendor/pcapng/__init__.py +51 -0
- pcapkit/vendor/pcapng/block_type.py +94 -0
- pcapkit/vendor/pcapng/filter_type.py +77 -0
- pcapkit/vendor/pcapng/hash_algorithm.py +82 -0
- pcapkit/vendor/pcapng/option_type.py +287 -0
- pcapkit/vendor/pcapng/record_type.py +81 -0
- pcapkit/vendor/pcapng/secrets_type.py +81 -0
- pcapkit/vendor/pcapng/verdict_type.py +79 -0
- pcapkit/vendor/reg/__init__.py +34 -0
- pcapkit/vendor/reg/apptype.py +338 -0
- pcapkit/vendor/reg/ethertype.py +121 -0
- pcapkit/vendor/reg/linktype.py +110 -0
- pcapkit/vendor/reg/transtype.py +111 -0
- pcapkit/vendor/tcp/__init__.py +35 -0
- pcapkit/vendor/tcp/checksum.py +80 -0
- pcapkit/vendor/tcp/flags.py +149 -0
- pcapkit/vendor/tcp/mp_tcp_option.py +90 -0
- pcapkit/vendor/tcp/option.py +103 -0
- pcapkit/vendor/vlan/__init__.py +23 -0
- pcapkit/vendor/vlan/priority_level.py +97 -0
- pypcapkit-1.3.3.post1.dist-info/LICENSE +29 -0
- pypcapkit-1.3.3.post1.dist-info/METADATA +236 -0
- pypcapkit-1.3.3.post1.dist-info/RECORD +466 -0
- pypcapkit-1.3.3.post1.dist-info/WHEEL +5 -0
- pypcapkit-1.3.3.post1.dist-info/entry_points.txt +3 -0
- pypcapkit-1.3.3.post1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,885 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
"""Protocol Registries
|
3
|
+
=========================
|
4
|
+
|
5
|
+
.. module:: pcapkit.foundation.registry.protocols
|
6
|
+
|
7
|
+
This module provides the protocol registries for :mod:`pcapkit`.
|
8
|
+
|
9
|
+
"""
|
10
|
+
from typing import TYPE_CHECKING, cast, overload
|
11
|
+
|
12
|
+
from pcapkit.const.reg.apptype import AppType as Enum_AppType
|
13
|
+
from pcapkit.const.reg.apptype import TransportProtocol
|
14
|
+
from pcapkit.corekit.module import ModuleDescriptor
|
15
|
+
from pcapkit.protocols import __proto__ as protocol_registry
|
16
|
+
from pcapkit.protocols.application.httpv2 import HTTP as HTTPv2
|
17
|
+
from pcapkit.protocols.internet.hip import HIP
|
18
|
+
from pcapkit.protocols.internet.hopopt import HOPOPT
|
19
|
+
from pcapkit.protocols.internet.internet import Internet
|
20
|
+
from pcapkit.protocols.internet.ipv4 import IPv4
|
21
|
+
from pcapkit.protocols.internet.ipv6_opts import IPv6_Opts
|
22
|
+
from pcapkit.protocols.internet.ipv6_route import IPv6_Route
|
23
|
+
from pcapkit.protocols.internet.mh import MH
|
24
|
+
from pcapkit.protocols.link.link import Link
|
25
|
+
from pcapkit.protocols.misc.pcap.frame import Frame
|
26
|
+
from pcapkit.protocols.misc.pcapng import PCAPNG
|
27
|
+
from pcapkit.protocols.protocol import ProtocolBase as Protocol
|
28
|
+
from pcapkit.protocols.schema.application.httpv2 import FrameType as Schema_HTTP_FrameType
|
29
|
+
from pcapkit.protocols.schema.internet.hip import Parameter as Schema_HIP_Parameter
|
30
|
+
from pcapkit.protocols.schema.internet.hopopt import Option as Schema_HOPOPT_Option
|
31
|
+
from pcapkit.protocols.schema.internet.ipv4 import Option as Schema_IPv4_Option
|
32
|
+
from pcapkit.protocols.schema.internet.ipv6_opts import Option as Schema_IPv6_Opts_Option
|
33
|
+
from pcapkit.protocols.schema.internet.ipv6_route import \
|
34
|
+
RoutingType as Schema_IPv6_Route_RoutingType
|
35
|
+
from pcapkit.protocols.schema.internet.mh import CGAExtension as Schema_MH_CGAExtension
|
36
|
+
from pcapkit.protocols.schema.internet.mh import Option as Schema_MH_Option
|
37
|
+
from pcapkit.protocols.schema.internet.mh import Packet as Schema_MH_Packet
|
38
|
+
from pcapkit.protocols.schema.misc.pcapng import BlockType as Schema_PCAPNG_BlockType
|
39
|
+
from pcapkit.protocols.schema.misc.pcapng import DSBSecrets as Schema_PCAPNG_DSBSecrets
|
40
|
+
from pcapkit.protocols.schema.misc.pcapng import \
|
41
|
+
NameResolutionRecord as Schema_PCAPNG_NameResolutionRecord
|
42
|
+
from pcapkit.protocols.schema.misc.pcapng import Option as Schema_PCAPNG_Option
|
43
|
+
from pcapkit.protocols.schema.transport.tcp import MPTCP as Schema_TCP_MPTCP
|
44
|
+
from pcapkit.protocols.schema.transport.tcp import Option as Schema_TCP_Option
|
45
|
+
from pcapkit.protocols.transport.tcp import TCP
|
46
|
+
from pcapkit.protocols.transport.udp import UDP
|
47
|
+
from pcapkit.utilities.exceptions import RegistryError
|
48
|
+
from pcapkit.utilities.logging import logger
|
49
|
+
|
50
|
+
if TYPE_CHECKING:
|
51
|
+
from typing import Optional, Type
|
52
|
+
|
53
|
+
from pcapkit.const.hip.parameter import Parameter as HIP_Parameter
|
54
|
+
from pcapkit.const.http.frame import Frame as HTTP_Frame
|
55
|
+
from pcapkit.const.ipv4.option_number import OptionNumber as IPv4_OptionNumber
|
56
|
+
from pcapkit.const.ipv6.option import Option as IPv6_Option
|
57
|
+
from pcapkit.const.ipv6.routing import Routing as IPv6_Routing
|
58
|
+
from pcapkit.const.mh.cga_extension import CGAExtension as MH_CGAExtension
|
59
|
+
from pcapkit.const.mh.option import Option as MH_Option
|
60
|
+
from pcapkit.const.mh.packet import Packet as MH_Packet
|
61
|
+
from pcapkit.const.pcapng.block_type import BlockType as PCAPNG_BlockType
|
62
|
+
from pcapkit.const.pcapng.option_type import OptionType as PCAPNG_OptionType
|
63
|
+
from pcapkit.const.pcapng.record_type import RecordType as PCAPNG_RecordType
|
64
|
+
from pcapkit.const.pcapng.secrets_type import SecretsType as PCAPNG_SecretsType
|
65
|
+
from pcapkit.const.reg.ethertype import EtherType
|
66
|
+
from pcapkit.const.reg.linktype import LinkType
|
67
|
+
from pcapkit.const.reg.transtype import TransType
|
68
|
+
from pcapkit.const.tcp.mp_tcp_option import MPTCPOption as TCP_MPTCPOption
|
69
|
+
from pcapkit.const.tcp.option import Option as TCP_Option
|
70
|
+
from pcapkit.protocols.application.httpv2 import FrameConstructor as HTTP_FrameConstructor
|
71
|
+
from pcapkit.protocols.application.httpv2 import FrameParser as HTTP_FrameParser
|
72
|
+
from pcapkit.protocols.internet.hip import ParameterConstructor as HIP_ParameterConstructor
|
73
|
+
from pcapkit.protocols.internet.hip import ParameterParser as HIP_ParameterParser
|
74
|
+
from pcapkit.protocols.internet.hopopt import OptionConstructor as HOPOPT_OptionConstructor
|
75
|
+
from pcapkit.protocols.internet.hopopt import OptionParser as HOPOPT_OptionParser
|
76
|
+
from pcapkit.protocols.internet.ipv4 import OptionConstructor as IPv4_OptionConstructor
|
77
|
+
from pcapkit.protocols.internet.ipv4 import OptionParser as IPv4_OptionParser
|
78
|
+
from pcapkit.protocols.internet.ipv6_opts import \
|
79
|
+
OptionConstructor as IPv6_Opts_OptionConstructor
|
80
|
+
from pcapkit.protocols.internet.ipv6_opts import OptionParser as IPv6_Opts_OptionParser
|
81
|
+
from pcapkit.protocols.internet.ipv6_route import TypeConstructor as IPv6_Route_TypeConstructor
|
82
|
+
from pcapkit.protocols.internet.ipv6_route import TypeParser as IPv6_Route_TypeParser
|
83
|
+
from pcapkit.protocols.internet.mh import ExtensionConstructor as MH_ExtensionConstructor
|
84
|
+
from pcapkit.protocols.internet.mh import ExtensionParser as MH_ExtensionParser
|
85
|
+
from pcapkit.protocols.internet.mh import OptionConstructor as MH_OptionConstructor
|
86
|
+
from pcapkit.protocols.internet.mh import OptionParser as MH_OptionParser
|
87
|
+
from pcapkit.protocols.internet.mh import PacketConstructor as MH_PacketConstructor
|
88
|
+
from pcapkit.protocols.internet.mh import PacketParser as MH_PacketParser
|
89
|
+
from pcapkit.protocols.misc.pcapng import BlockConstructor as PCAPNG_BlockConstructor
|
90
|
+
from pcapkit.protocols.misc.pcapng import BlockParser as PCAPNG_BlockParser
|
91
|
+
from pcapkit.protocols.misc.pcapng import OptionConstructor as PCAPNG_OptionConstructor
|
92
|
+
from pcapkit.protocols.misc.pcapng import OptionParser as PCAPNG_OptionParser
|
93
|
+
from pcapkit.protocols.misc.pcapng import RecordConstructor as PCAPNG_RecordConstructor
|
94
|
+
from pcapkit.protocols.misc.pcapng import RecordParser as PCAPNG_RecordParser
|
95
|
+
from pcapkit.protocols.misc.pcapng import SecretsConstructor as PCAPNG_SecretsConstructor
|
96
|
+
from pcapkit.protocols.misc.pcapng import SecretsParser as PCAPNG_SecretsParser
|
97
|
+
from pcapkit.protocols.transport.tcp import MPOptionConstructor as TCP_MPOptionConstructor
|
98
|
+
from pcapkit.protocols.transport.tcp import MPOptionParser as TCP_MPOptionParser
|
99
|
+
from pcapkit.protocols.transport.tcp import OptionConstructor as TCP_OptionConstructor
|
100
|
+
from pcapkit.protocols.transport.tcp import OptionParser as TCP_OptionParser
|
101
|
+
|
102
|
+
__all__ = [
|
103
|
+
'register_protocol',
|
104
|
+
|
105
|
+
'register_linktype',
|
106
|
+
'register_pcap', 'register_pcapng',
|
107
|
+
|
108
|
+
'register_ethertype',
|
109
|
+
|
110
|
+
'register_transtype',
|
111
|
+
'register_ipv4_option', 'register_hip_parameter', 'register_hopopt_option',
|
112
|
+
'register_ipv6_opts_option', 'register_ipv6_route_routing',
|
113
|
+
'register_mh_message', 'register_mh_option', 'register_mh_extension',
|
114
|
+
|
115
|
+
'register_apptype',
|
116
|
+
'register_tcp', 'register_udp',
|
117
|
+
'register_tcp_option', 'register_tcp_mp_option',
|
118
|
+
|
119
|
+
'register_http_frame',
|
120
|
+
|
121
|
+
'register_pcapng_block', 'register_pcapng_option', 'register_pcapng_secrets',
|
122
|
+
'register_pcapng_record',
|
123
|
+
]
|
124
|
+
|
125
|
+
NULL = '(null)'
|
126
|
+
|
127
|
+
|
128
|
+
# NOTE: pcapkit.protocols.__proto__
|
129
|
+
def register_protocol(protocol: 'Type[Protocol]') -> 'None':
|
130
|
+
"""Registered protocol class.
|
131
|
+
|
132
|
+
The protocol class must be a subclass of
|
133
|
+
:class:`~pcapkit.protocols.protocol.Protocol`, and will be registered to
|
134
|
+
the :data:`pcapkit.protocols.__proto__` registry.
|
135
|
+
|
136
|
+
Args:
|
137
|
+
protocol: Protocol class.
|
138
|
+
|
139
|
+
"""
|
140
|
+
if not issubclass(protocol, Protocol):
|
141
|
+
raise RegistryError(f'protocol must be a Protocol subclass, not {protocol!r}')
|
142
|
+
|
143
|
+
protocol_registry[protocol.__name__.upper()] = protocol
|
144
|
+
logger.info('registered protocol: %s', protocol.__name__)
|
145
|
+
|
146
|
+
|
147
|
+
###############################################################################
|
148
|
+
# Top-Level Registries
|
149
|
+
###############################################################################
|
150
|
+
|
151
|
+
|
152
|
+
@overload
|
153
|
+
def register_linktype(code: 'LinkType', module: 'ModuleDescriptor[Protocol] | Type[Protocol]') -> 'None': ...
|
154
|
+
@overload
|
155
|
+
def register_linktype(code: 'LinkType', module: 'str', class_: 'str') -> 'None': ...
|
156
|
+
|
157
|
+
|
158
|
+
def register_linktype(code: 'LinkType', module: 'str | ModuleDescriptor[Protocol] | Type[Protocol]',
|
159
|
+
class_: 'str' = NULL) -> 'None':
|
160
|
+
r"""Register a new protocol class.
|
161
|
+
|
162
|
+
Notes:
|
163
|
+
The full qualified class name of the new protocol class
|
164
|
+
should be as ``{module}.{class_}``.
|
165
|
+
|
166
|
+
The function will register the given protocol class to the
|
167
|
+
following registries:
|
168
|
+
|
169
|
+
- :data:`pcapkit.protocols.misc.pcap.frame.Frame.__proto__`
|
170
|
+
- :data:`pcapkit.protocols.misc.pcapng.PCAPNG.__proto__`
|
171
|
+
|
172
|
+
Arguments:
|
173
|
+
code: protocol code as in :class:`~pcapkit.const.reg.linktype.LinkType`
|
174
|
+
module: module name or module descriptor or a
|
175
|
+
:class:`~pcapkit.protocols.protocol.Protocol` subclass
|
176
|
+
class\_: class name
|
177
|
+
|
178
|
+
See Also:
|
179
|
+
* :func:`pcapkit.foundation.registry.protocols.register_pcap`
|
180
|
+
* :func:`pcapkit.foundation.registry.protocols.register_pcapng`
|
181
|
+
|
182
|
+
"""
|
183
|
+
if isinstance(module, str):
|
184
|
+
module = cast('ModuleDescriptor[Protocol]', ModuleDescriptor(module, class_))
|
185
|
+
|
186
|
+
Frame.register(code, module)
|
187
|
+
PCAPNG.register(code, module)
|
188
|
+
logger.info('registered linktype protocol: %s', code.name)
|
189
|
+
|
190
|
+
# register protocol to protocol registry
|
191
|
+
if isinstance(module, ModuleDescriptor):
|
192
|
+
module = module.klass
|
193
|
+
register_protocol(module)
|
194
|
+
|
195
|
+
|
196
|
+
@overload
|
197
|
+
def register_pcap(code: 'LinkType', module: 'ModuleDescriptor[Protocol] | Type[Protocol]') -> 'None': ...
|
198
|
+
@overload
|
199
|
+
def register_pcap(code: 'LinkType', module: 'str', class_: 'str') -> 'None': ...
|
200
|
+
|
201
|
+
|
202
|
+
# NOTE: pcapkit.protocols.misc.pcap.frame.Frame.__proto__
|
203
|
+
def register_pcap(code: 'LinkType', module: 'str | ModuleDescriptor[Protocol] | Type[Protocol]',
|
204
|
+
class_: 'str' = NULL) -> 'None':
|
205
|
+
r"""Register a new protocol class.
|
206
|
+
|
207
|
+
Notes:
|
208
|
+
The full qualified class name of the new protocol class
|
209
|
+
should be as ``{module}.{class_}``.
|
210
|
+
|
211
|
+
The function will register the given protocol class to the
|
212
|
+
:data:`pcapkit.protocols.misc.pcap.frame.Frame.__proto__` registry.
|
213
|
+
|
214
|
+
Arguments:
|
215
|
+
code: protocol code as in :class:`~pcapkit.const.reg.linktype.LinkType`
|
216
|
+
module: module name or module descriptor or a
|
217
|
+
:class:`~pcapkit.protocols.protocol.Protocol` subclass
|
218
|
+
class\_: class name
|
219
|
+
|
220
|
+
"""
|
221
|
+
if isinstance(module, str):
|
222
|
+
module = cast('ModuleDescriptor[Protocol]', ModuleDescriptor(module, class_))
|
223
|
+
|
224
|
+
Frame.register(code, module)
|
225
|
+
logger.info('registered PCAP linktype protocol: %s', code.name)
|
226
|
+
|
227
|
+
# register protocol to protocol registry
|
228
|
+
if isinstance(module, ModuleDescriptor):
|
229
|
+
module = module.klass
|
230
|
+
register_protocol(module)
|
231
|
+
|
232
|
+
|
233
|
+
@overload
|
234
|
+
def register_pcapng(code: 'LinkType', module: 'ModuleDescriptor[Protocol] | Type[Protocol]') -> 'None': ...
|
235
|
+
@overload
|
236
|
+
def register_pcapng(code: 'LinkType', module: 'str', class_: 'str') -> 'None': ...
|
237
|
+
|
238
|
+
|
239
|
+
# NOTE: pcapkit.protocols.misc.pcapng.PCAPNG.__proto__
|
240
|
+
def register_pcapng(code: 'LinkType', module: 'str | ModuleDescriptor[Protocol] | Type[Protocol]',
|
241
|
+
class_: 'str' = NULL) -> 'None':
|
242
|
+
r"""Register a new protocol class.
|
243
|
+
|
244
|
+
Notes:
|
245
|
+
The full qualified class name of the new protocol class
|
246
|
+
should be as ``{module}.{class_}``.
|
247
|
+
|
248
|
+
The function will register the given protocol class to the
|
249
|
+
:data:`pcapkit.protocols.misc.pcapng.PCAPNG.__proto__` registry.
|
250
|
+
|
251
|
+
Arguments:
|
252
|
+
code: protocol code as in :class:`~pcapkit.const.reg.linktype.LinkType`
|
253
|
+
module: module name or module descriptor or a
|
254
|
+
:class:`~pcapkit.protocols.protocol.Protocol` subclass
|
255
|
+
class\_: class name
|
256
|
+
|
257
|
+
"""
|
258
|
+
if isinstance(module, str):
|
259
|
+
module = cast('ModuleDescriptor[Protocol]', ModuleDescriptor(module, class_))
|
260
|
+
|
261
|
+
PCAPNG.register(code, module)
|
262
|
+
logger.info('registered PCAP-NG linktype protocol: %s', code.name)
|
263
|
+
|
264
|
+
# register protocol to protocol registry
|
265
|
+
if isinstance(module, ModuleDescriptor):
|
266
|
+
module = module.klass
|
267
|
+
register_protocol(module)
|
268
|
+
|
269
|
+
|
270
|
+
###############################################################################
|
271
|
+
# Link Layer Registries
|
272
|
+
###############################################################################
|
273
|
+
|
274
|
+
|
275
|
+
@overload
|
276
|
+
def register_ethertype(code: 'EtherType', module: 'ModuleDescriptor[Protocol] | Type[Protocol]') -> 'None': ...
|
277
|
+
@overload
|
278
|
+
def register_ethertype(code: 'EtherType', module: 'str', class_: 'str') -> 'None': ...
|
279
|
+
|
280
|
+
|
281
|
+
# NOTE: pcapkit.protocols.link.link.Link.__proto__
|
282
|
+
def register_ethertype(code: 'EtherType', module: 'str | ModuleDescriptor[Protocol] | Type[Protocol]',
|
283
|
+
class_: 'str' = NULL) -> 'None':
|
284
|
+
r"""Register a new protocol class.
|
285
|
+
|
286
|
+
Notes:
|
287
|
+
The full qualified class name of the new protocol class
|
288
|
+
should be as ``{module}.{class_}``.
|
289
|
+
|
290
|
+
The function will register the given protocol class to the
|
291
|
+
:data:`pcapkit.protocols.link.link.Link.__proto__` registry.
|
292
|
+
|
293
|
+
Arguments:
|
294
|
+
code: protocol code as in :class:`~pcapkit.const.reg.ethertype.EtherType`
|
295
|
+
module: module name or module descriptor or a
|
296
|
+
:class:`~pcapkit.protocols.protocol.Protocol` subclass
|
297
|
+
class\_: class name
|
298
|
+
|
299
|
+
"""
|
300
|
+
if isinstance(module, str):
|
301
|
+
module = cast('ModuleDescriptor[Protocol]', ModuleDescriptor(module, class_))
|
302
|
+
|
303
|
+
Link.register(code, module)
|
304
|
+
logger.info('registered ethertype protocol: %s', code.name)
|
305
|
+
|
306
|
+
# register protocol to protocol registry
|
307
|
+
if isinstance(module, ModuleDescriptor):
|
308
|
+
module = module.klass
|
309
|
+
register_protocol(module)
|
310
|
+
|
311
|
+
|
312
|
+
###############################################################################
|
313
|
+
# Internet Layer Registries
|
314
|
+
###############################################################################
|
315
|
+
|
316
|
+
|
317
|
+
@overload
|
318
|
+
def register_transtype(code: 'TransType', module: 'ModuleDescriptor[Protocol] | Type[Protocol]') -> 'None': ...
|
319
|
+
@overload
|
320
|
+
def register_transtype(code: 'TransType', module: 'str', class_: 'str') -> 'None': ...
|
321
|
+
|
322
|
+
|
323
|
+
# NOTE: pcapkit.protocols.internet.internet.Internet.__proto__
|
324
|
+
def register_transtype(code: 'TransType', module: 'str | ModuleDescriptor[Protocol] | Type[Protocol]',
|
325
|
+
class_: 'str' = NULL) -> 'None':
|
326
|
+
r"""Register a new protocol class.
|
327
|
+
|
328
|
+
Notes:
|
329
|
+
The full qualified class name of the new protocol class
|
330
|
+
should be as ``{module}.{class_}``.
|
331
|
+
|
332
|
+
The function will register the given protocol class to the
|
333
|
+
:data:`pcapkit.protocols.internet.internet.Internet.__proto__` registry.
|
334
|
+
|
335
|
+
Arguments:
|
336
|
+
code: protocol code as in :class:`~pcapkit.const.reg.transtype.TransType`
|
337
|
+
module: module name or module descriptor or a
|
338
|
+
:class:`~pcapkit.protocols.protocol.Protocol` subclass
|
339
|
+
class\_: class name
|
340
|
+
|
341
|
+
"""
|
342
|
+
if isinstance(module, str):
|
343
|
+
module = cast('ModuleDescriptor[Protocol]', ModuleDescriptor(module, class_))
|
344
|
+
|
345
|
+
Internet.register(code, module)
|
346
|
+
logger.info('registered transtype protocol: %s', code.name)
|
347
|
+
|
348
|
+
# register protocol to protocol registry
|
349
|
+
if isinstance(module, ModuleDescriptor):
|
350
|
+
module = module.klass
|
351
|
+
register_protocol(module)
|
352
|
+
|
353
|
+
|
354
|
+
# NOTE: pcapkit.protocols.internet.internet.IPv4
|
355
|
+
def register_ipv4_option(code: 'IPv4_OptionNumber', meth: 'str | tuple[IPv4_OptionParser, IPv4_OptionConstructor]', *,
|
356
|
+
schema: 'Optional[Type[Schema_IPv4_Option]]' = None) -> 'None':
|
357
|
+
"""Register an option parser.
|
358
|
+
|
359
|
+
The function will register the given option parser to the
|
360
|
+
:data:`pcapkit.protocols.internet.internet.IPv4` internal registry.
|
361
|
+
|
362
|
+
Args:
|
363
|
+
code: :class:`IPv4 <pcapkit.protocols.internet.ipv4.IPv4>` option code as
|
364
|
+
in :class:`~pcapkit.const.ipv4.option_number.OptionNumber`.
|
365
|
+
meth: Method name or callable to parse and/or construct the option.
|
366
|
+
schema: :class:`~pcapkit.protocols.schema.schema.Schema` class for the option.
|
367
|
+
It should be a subclass of :class:`pcapkit.protocols.schema.internet.ipv4.Option`.
|
368
|
+
|
369
|
+
"""
|
370
|
+
if isinstance(meth, str) and not hasattr(IPv4, f'_read_opt_{meth}'):
|
371
|
+
raise RegistryError('method must be a valid IPv4 option parser function')
|
372
|
+
|
373
|
+
IPv4.register_option(code, meth)
|
374
|
+
if schema is not None:
|
375
|
+
Schema_IPv4_Option.register(code, schema)
|
376
|
+
logger.info('registered IPv4 option parser: %s', code.name)
|
377
|
+
|
378
|
+
|
379
|
+
# NOTE: pcapkit.protocols.internet.hip.HIP
|
380
|
+
def register_hip_parameter(code: 'HIP_Parameter', meth: 'str | tuple[HIP_ParameterParser, HIP_ParameterConstructor]', *,
|
381
|
+
schema: 'Optional[Type[Schema_HIP_Parameter]]' = None) -> 'None':
|
382
|
+
"""Register a parameter parser.
|
383
|
+
|
384
|
+
The function will register the given parameter parser to the
|
385
|
+
:data:`pcapkit.protocols.internet.hip.HIP` internal registry.
|
386
|
+
|
387
|
+
Args:
|
388
|
+
code: :class:`~pcapkit.protocols.internet.hip.HIP` parameter code as
|
389
|
+
in :class:`~pcapkit.const.hip.parameter.Parameter`.
|
390
|
+
meth: Method name or callable to parse and/or construct the parameter.
|
391
|
+
schema: :class:`~pcapkit.protocols.schema.schema.Schema` class for the parameter.
|
392
|
+
It should be a subclass of :class:`pcapkit.protocols.schema.internet.hip.Parameter`.
|
393
|
+
|
394
|
+
"""
|
395
|
+
if isinstance(meth, str) and not hasattr(HIP, f'_read_param_{meth}'):
|
396
|
+
raise RegistryError('method must be a valid HIP parameter parser function')
|
397
|
+
|
398
|
+
HIP.register_parameter(code, meth)
|
399
|
+
if schema is not None:
|
400
|
+
Schema_HIP_Parameter.register(code, schema)
|
401
|
+
logger.info('registered HIP parameter parser: %s', code.name)
|
402
|
+
|
403
|
+
|
404
|
+
# NOTE: pcapkit.protocols.internet.hopopt.HOPOPT.__option__
|
405
|
+
def register_hopopt_option(code: 'IPv6_Option', meth: 'str | tuple[HOPOPT_OptionParser, HOPOPT_OptionConstructor]', *,
|
406
|
+
schema: 'Optional[Type[Schema_HOPOPT_Option]]' = None) -> 'None':
|
407
|
+
"""Register an option parser.
|
408
|
+
|
409
|
+
The function will register the given option parser to the
|
410
|
+
:data:`pcapkit.protocols.internet.hopopt.HOPOPT.__option__` registry.
|
411
|
+
|
412
|
+
Args:
|
413
|
+
code: :class:`~pcapkit.protocols.internet.hopopt.HOPOPT` option code as
|
414
|
+
in :class:`~pcapkit.const.ipv6.option.Option`.
|
415
|
+
meth: Method name or callable to parse and/or construct the option.
|
416
|
+
schema: :class:`~pcapkit.protocols.schema.schema.Schema` class for the option.
|
417
|
+
It should be a subclass of :class:`pcapkit.protocols.schema.internet.hopopt.Option`.
|
418
|
+
|
419
|
+
"""
|
420
|
+
if isinstance(meth, str) and not hasattr(HOPOPT, f'_read_opt_{meth}'):
|
421
|
+
raise RegistryError('method must be a valid HOPOPT option parser function')
|
422
|
+
|
423
|
+
HOPOPT.register_option(code, meth)
|
424
|
+
if schema is not None:
|
425
|
+
Schema_HOPOPT_Option.register(code, schema)
|
426
|
+
logger.info('registered HOPOPT option parser: %s', code.name)
|
427
|
+
|
428
|
+
|
429
|
+
# NOTE: pcapkit.protocols.internet.ipv6_opts.IPv6_Opts.__option__
|
430
|
+
def register_ipv6_opts_option(code: 'IPv6_Option', meth: 'str | tuple[IPv6_Opts_OptionParser, IPv6_Opts_OptionConstructor]', *,
|
431
|
+
schema: 'Optional[Type[Schema_IPv6_Opts_Option]]' = None) -> 'None':
|
432
|
+
"""Register an option parser.
|
433
|
+
|
434
|
+
The function will register the given option parser to the
|
435
|
+
:data:`pcapkit.protocols.internet.ipv6_opts.IPv6_Opts.__option__` registry.
|
436
|
+
|
437
|
+
Args:
|
438
|
+
code: :class:`IPv6-Opts <pcapkit.protocols.internet.ipv6_opts.IPv6_Opts>`
|
439
|
+
option code as in :class:`~pcapkit.const.ipv6.option.Option`.
|
440
|
+
meth: Method name or callable to parse and/or construct the option.
|
441
|
+
schema: :class:`~pcapkit.protocols.schema.schema.Schema` class for the option.
|
442
|
+
It should be a subclass of :class:`pcapkit.protocols.schema.internet.ipv6_opts.Option`.
|
443
|
+
|
444
|
+
"""
|
445
|
+
if isinstance(meth, str) and not hasattr(IPv6_Opts, f'_read_opt_{meth}'):
|
446
|
+
raise RegistryError('method must be a valid IPv6-Opts option parser function')
|
447
|
+
|
448
|
+
IPv6_Opts.register_option(code, meth)
|
449
|
+
if schema is not None:
|
450
|
+
Schema_IPv6_Opts_Option.register(code, schema)
|
451
|
+
logger.info('registered IPv6-Opts option parser: %s', code.name)
|
452
|
+
|
453
|
+
|
454
|
+
# NOTE: pcapkit.protocols.internet.ipv6_route.IPv6_Route.__routing__
|
455
|
+
def register_ipv6_route_routing(code: 'IPv6_Routing', meth: 'str | tuple[IPv6_Route_TypeParser, IPv6_Route_TypeConstructor]', *,
|
456
|
+
schema: 'Optional[Type[Schema_IPv6_Route_RoutingType]]' = None) -> 'None':
|
457
|
+
"""Register a routing data parser.
|
458
|
+
|
459
|
+
The function will register the given routing data parser to the
|
460
|
+
:data:`pcapkit.protocols.internet.ipv6_route.IPv6_Route.__routing__` registry.
|
461
|
+
|
462
|
+
Args:
|
463
|
+
code: :class:`IPv6-Route <pcapkit.protocols.internet.ipv6_route.IPv6_Route>`
|
464
|
+
data type code as in :class:`~pcapkit.const.ipv6.routing.Routing`.
|
465
|
+
meth: Method name or callable to parse and/or construct the data.
|
466
|
+
schema: :class:`~pcapkit.protocols.schema.schema.Schema` class for the routing data.
|
467
|
+
It should be a subclass of :class:`pcapkit.protocols.schema.internet.ipv6_route.RoutingType`.
|
468
|
+
|
469
|
+
"""
|
470
|
+
if isinstance(meth, str) and not hasattr(IPv6_Route, f'_read_data_type_{meth}'):
|
471
|
+
raise RegistryError('method must be a valid IPv6-Route routing data parser function')
|
472
|
+
|
473
|
+
IPv6_Route.register_routing(code, meth)
|
474
|
+
if schema is not None:
|
475
|
+
Schema_IPv6_Route_RoutingType.register(code, schema)
|
476
|
+
logger.info('registered IPv6-Route routing data parser: %s', code.name)
|
477
|
+
|
478
|
+
|
479
|
+
# NOTE: pcapkit.protocols.internet.mh.MH.__message__
|
480
|
+
def register_mh_message(code: 'MH_Packet', meth: 'str | tuple[MH_PacketParser, MH_PacketConstructor]', *,
|
481
|
+
schema: 'Optional[Type[Schema_MH_Packet]]' = None) -> 'None':
|
482
|
+
"""Register a MH message type parser.
|
483
|
+
|
484
|
+
The function will register the given message type parser to the
|
485
|
+
:data:`pcapkit.protocols.internet.mh.MH.__message__` registry.
|
486
|
+
|
487
|
+
Args:
|
488
|
+
code: :class:`~pcapkit.protocols.internet.mh.MH>`
|
489
|
+
data type code as in :class:`~pcapkit.const.mh.packet.Packet`.
|
490
|
+
meth: Method name or callable to parse and/or construct the data.
|
491
|
+
schema: :class:`~pcapkit.protocols.schema.schema.Schema` class for the message type.
|
492
|
+
It should be a subclass of :class:`pcapkit.protocols.schema.internet.mh.Packet`.
|
493
|
+
|
494
|
+
"""
|
495
|
+
if isinstance(meth, str) and not hasattr(MH, f'_read_msg_{meth}'):
|
496
|
+
raise RegistryError('method must be a valid MH message type parser function')
|
497
|
+
|
498
|
+
MH.register_message(code, meth)
|
499
|
+
if schema is not None:
|
500
|
+
Schema_MH_Packet.register(code, schema)
|
501
|
+
logger.info('registered MH message type parser: %s', code.name)
|
502
|
+
|
503
|
+
|
504
|
+
# NOTE: pcapkit.protocols.internet.mh.MH.__option__
|
505
|
+
def register_mh_option(code: 'MH_Option', meth: 'str | tuple[MH_OptionParser, MH_OptionConstructor]', *,
|
506
|
+
schema: 'Optional[Type[Schema_MH_Option]]' = None) -> 'None':
|
507
|
+
"""Register a MH option parser.
|
508
|
+
|
509
|
+
The function will register the given option parser to the
|
510
|
+
:data:`pcapkit.protocols.internet.mh.MH.__option__` registry.
|
511
|
+
|
512
|
+
Args:
|
513
|
+
code: :class:`~pcapkit.protocols.internet.mh.MH>`
|
514
|
+
data type code as in :class:`~pcapkit.const.mh.option.Option`.
|
515
|
+
meth: Method name or callable to parse and/or construct the data.
|
516
|
+
schema: :class:`~pcapkit.protocols.schema.schema.Schema` class for the message type.
|
517
|
+
It should be a subclass of :class:`pcapkit.protocols.schema.internet.mh.Option`.
|
518
|
+
|
519
|
+
"""
|
520
|
+
if isinstance(meth, str) and not hasattr(MH, f'_read_opt_{meth}'):
|
521
|
+
raise RegistryError('method must be a valid MH option parser function')
|
522
|
+
|
523
|
+
MH.register_option(code, meth)
|
524
|
+
if schema is not None:
|
525
|
+
Schema_MH_Option.register(code, schema)
|
526
|
+
logger.info('registered MH option parser: %s', code.name)
|
527
|
+
|
528
|
+
|
529
|
+
# NOTE: pcapkit.protocols.internet.mh.MH.__extension__
|
530
|
+
def register_mh_extension(code: 'MH_CGAExtension', meth: 'str | tuple[MH_ExtensionParser, MH_ExtensionConstructor]',
|
531
|
+
schema: 'Optional[Type[Schema_MH_CGAExtension]]' = None) -> 'None':
|
532
|
+
"""Register a CGA extension parser.
|
533
|
+
|
534
|
+
The function will register the given CGA extension to the
|
535
|
+
:data:`pcapkit.protocols.internet.mh.MH.__extension__` registry.
|
536
|
+
|
537
|
+
Args:
|
538
|
+
code: :class:`~pcapkit.protocols.internet.mh.MH>`
|
539
|
+
data type code as in :class:`~pcapkit.const.mh.cga_extension.CGAExtension`.
|
540
|
+
meth: Method name or callable to parse and/or construct the data.
|
541
|
+
schema: :class:`~pcapkit.protocols.schema.schema.Schema` class for the message type.
|
542
|
+
It should be a subclass of :class:`pcapkit.protocols.schema.internet.mh.CGAExtension`.
|
543
|
+
|
544
|
+
"""
|
545
|
+
if isinstance(meth, str) and not hasattr(MH, f'_read_ext_{meth}'):
|
546
|
+
raise RegistryError('method must be a valid MH CGA extension function')
|
547
|
+
|
548
|
+
MH.register_extension(code, meth)
|
549
|
+
if schema is not None:
|
550
|
+
Schema_MH_CGAExtension.register(code, schema)
|
551
|
+
logger.info('registered MH CGA extension: %s', code.name)
|
552
|
+
|
553
|
+
|
554
|
+
###############################################################################
|
555
|
+
# Transport Layer Registries
|
556
|
+
###############################################################################
|
557
|
+
|
558
|
+
|
559
|
+
@overload
|
560
|
+
def register_apptype(code: 'int', module: 'ModuleDescriptor[Protocol] | Type[Protocol]', *, proto: 'TransportProtocol | str') -> 'None': ...
|
561
|
+
@overload
|
562
|
+
def register_apptype(code: 'Enum_AppType', module: 'ModuleDescriptor[Protocol] | Type[Protocol]', *, proto: 'TransportProtocol | str' = ...) -> 'None': ...
|
563
|
+
@overload
|
564
|
+
def register_apptype(code: 'int', module: 'str', class_: 'str', *, proto: 'TransportProtocol | str') -> 'None': ...
|
565
|
+
@overload
|
566
|
+
def register_apptype(code: 'Enum_AppType', module: 'str', class_: 'str', *, proto: 'TransportProtocol | str' = ...) -> 'None': ...
|
567
|
+
|
568
|
+
|
569
|
+
def register_apptype(code: 'int | Enum_AppType', module: 'str | ModuleDescriptor[Protocol] | Type[Protocol]',
|
570
|
+
class_: 'str' = NULL, *, proto: 'TransportProtocol | str' = NULL) -> 'None':
|
571
|
+
r"""Register a new protocol class.
|
572
|
+
|
573
|
+
Notes:
|
574
|
+
The full qualified class name of the new protocol class
|
575
|
+
should be as ``{module}.{class_}``.
|
576
|
+
|
577
|
+
The function will register the given protocol class to the
|
578
|
+
:data:`pcapkit.protocols.transport.tcp.TCP.__proto__` and/or
|
579
|
+
:data:`pcapkit.protocols.transport.udp.UDP.__proto__` registry.
|
580
|
+
|
581
|
+
Arguments:
|
582
|
+
code: port number
|
583
|
+
module: module name or module descriptor or a
|
584
|
+
:class:`~pcapkit.protocols.protocol.Protocol` subclass
|
585
|
+
class\_: class name
|
586
|
+
proto: protocol name (must be a valid transport protocol)
|
587
|
+
|
588
|
+
See Also:
|
589
|
+
* :func:`pcapkit.foundation.registry.register_tcp`
|
590
|
+
* :func:`pcapkit.foundation.registry.register_udp`
|
591
|
+
|
592
|
+
"""
|
593
|
+
if isinstance(code, Enum_AppType):
|
594
|
+
if proto is NULL:
|
595
|
+
proto = code.proto
|
596
|
+
code = code.port
|
597
|
+
if isinstance(module, str):
|
598
|
+
module = cast('ModuleDescriptor[Protocol]', ModuleDescriptor(module, class_))
|
599
|
+
|
600
|
+
_reg = False
|
601
|
+
if isinstance(proto, str):
|
602
|
+
proto = TransportProtocol.get(proto.lower())
|
603
|
+
|
604
|
+
for test, cls in cast('dict[TransportProtocol, Type[Protocol]]', {
|
605
|
+
TransportProtocol.tcp: TCP,
|
606
|
+
TransportProtocol.udp: UDP,
|
607
|
+
}).items():
|
608
|
+
if test not in proto:
|
609
|
+
continue
|
610
|
+
|
611
|
+
cls.register(code, module)
|
612
|
+
logger.info('registered %s port: %s', test.name, code)
|
613
|
+
_reg = True
|
614
|
+
|
615
|
+
if not _reg:
|
616
|
+
raise RegistryError(f'unknown transport protocol: {proto.name}')
|
617
|
+
|
618
|
+
# register protocol to protocol registry
|
619
|
+
if isinstance(module, ModuleDescriptor):
|
620
|
+
module = module.klass
|
621
|
+
register_protocol(module)
|
622
|
+
|
623
|
+
|
624
|
+
@overload
|
625
|
+
def register_tcp(code: 'int | Enum_AppType', module: 'ModuleDescriptor[Protocol] | Type[Protocol]') -> 'None': ...
|
626
|
+
@overload
|
627
|
+
def register_tcp(code: 'int | Enum_AppType', module: 'str', class_: 'str') -> 'None': ...
|
628
|
+
|
629
|
+
|
630
|
+
# NOTE: pcapkit.protocols.transport.tcp.TCP.__proto__
|
631
|
+
def register_tcp(code: 'int | Enum_AppType', module: 'str | ModuleDescriptor[Protocol] | Type[Protocol]',
|
632
|
+
class_: 'str' = NULL) -> 'None':
|
633
|
+
r"""Register a new protocol class.
|
634
|
+
|
635
|
+
Notes:
|
636
|
+
The full qualified class name of the new protocol class
|
637
|
+
should be as ``{module}.{class_}``.
|
638
|
+
|
639
|
+
The function will register the given protocol class to the
|
640
|
+
:data:`pcapkit.protocols.transport.tcp.TCP.__proto__` registry.
|
641
|
+
|
642
|
+
Arguments:
|
643
|
+
code: port number
|
644
|
+
module: module name or module descriptor or a
|
645
|
+
:class:`~pcapkit.protocols.protocol.Protocol` subclass
|
646
|
+
class\_: class name
|
647
|
+
|
648
|
+
"""
|
649
|
+
if isinstance(code, Enum_AppType):
|
650
|
+
code = code.port
|
651
|
+
if isinstance(module, str):
|
652
|
+
module = cast('ModuleDescriptor[Protocol]', ModuleDescriptor(module, class_))
|
653
|
+
|
654
|
+
TCP.register(code, module)
|
655
|
+
logger.info('registered TCP port: %s', code)
|
656
|
+
|
657
|
+
# register protocol to protocol registry
|
658
|
+
if isinstance(module, ModuleDescriptor):
|
659
|
+
module = module.klass
|
660
|
+
register_protocol(module)
|
661
|
+
|
662
|
+
|
663
|
+
# NOTE: pcapkit.protocols.transport.tcp.TCP.__option__
|
664
|
+
def register_tcp_option(code: 'TCP_Option', meth: 'str | tuple[TCP_OptionParser, TCP_OptionConstructor]', *,
|
665
|
+
schema: 'Optional[Type[Schema_TCP_Option]]' = None) -> 'None':
|
666
|
+
"""Register an option parser.
|
667
|
+
|
668
|
+
The function will register the given option parser to the
|
669
|
+
:data:`pcapkit.protocols.transport.tcp.TCP.__option__` registry.
|
670
|
+
|
671
|
+
Args:
|
672
|
+
code: :class:`~pcapkit.protocols.transport.tcp.TCP` option code as in
|
673
|
+
:class:`~pcapkit.const.tcp.option.Option`.
|
674
|
+
meth: Method name or callable to parse and/or construct the option.
|
675
|
+
schema: :class:`~pcapkit.protocols.schema.schema.Schema` class for the option.
|
676
|
+
It should be a subclass of :class:`pcapkit.protocols.schema.transport.tcp.Option`.
|
677
|
+
|
678
|
+
"""
|
679
|
+
if isinstance(meth, str) and not hasattr(TCP, f'_read_mode_{meth}'):
|
680
|
+
raise RegistryError('method must be a TCP option parser function')
|
681
|
+
|
682
|
+
TCP.register_option(code, meth)
|
683
|
+
if schema is not None:
|
684
|
+
Schema_TCP_Option.register(code, schema)
|
685
|
+
logger.info('registered TCP option parser: %s', code.name)
|
686
|
+
|
687
|
+
|
688
|
+
# NOTE: pcapkit.protocols.transport.tcp.TCP.__mp_option__
|
689
|
+
def register_tcp_mp_option(code: 'TCP_MPTCPOption', meth: 'str | tuple[TCP_MPOptionParser, TCP_MPOptionConstructor]', *,
|
690
|
+
schema: 'Optional[Type[Schema_TCP_MPTCP]]' = None) -> 'None':
|
691
|
+
"""Register an MPTCP option parser.
|
692
|
+
|
693
|
+
The function will register the given option parser to the
|
694
|
+
:data:`pcapkit.protocols.transport.tcp.TCP.__mp_option__` registry.
|
695
|
+
|
696
|
+
Args:
|
697
|
+
code: Multipath :class:`~pcapkit.protocols.transport.tcp.TCP` option code as in
|
698
|
+
:class:`~pcapkit.const.tcp.mp_tcp_option.MPTCPOption`.
|
699
|
+
meth: Method name or callable to parse and/or construct the option.
|
700
|
+
schema: :class:`~pcapkit.protocols.schema.schema.Schema` class for the option.
|
701
|
+
It should be a subclass of :class:`pcapkit.protocols.schema.transport.tcp.MPTCP`.
|
702
|
+
|
703
|
+
"""
|
704
|
+
if isinstance(meth, str) and not hasattr(TCP, f'_read_mptcp_{meth}'):
|
705
|
+
raise RegistryError('method must be a MPTCP option parser function')
|
706
|
+
|
707
|
+
TCP.register_mp_option(code, meth)
|
708
|
+
if schema is not None:
|
709
|
+
Schema_TCP_MPTCP.register(code, schema)
|
710
|
+
logger.info('registered MPTCP option parser: %s', code.name)
|
711
|
+
|
712
|
+
|
713
|
+
@overload
|
714
|
+
def register_udp(code: 'int | Enum_AppType', module: 'ModuleDescriptor[Protocol] | Type[Protocol]') -> 'None': ...
|
715
|
+
@overload
|
716
|
+
def register_udp(code: 'int | Enum_AppType', module: 'str', class_: 'str') -> 'None': ...
|
717
|
+
|
718
|
+
|
719
|
+
# NOTE: pcapkit.protocols.transport.udp.UDP.__proto__
|
720
|
+
def register_udp(code: 'int | Enum_AppType', module: 'str | ModuleDescriptor[Protocol] | Type[Protocol]',
|
721
|
+
class_: 'str' = NULL) -> 'None':
|
722
|
+
r"""Register a new protocol class.
|
723
|
+
|
724
|
+
Notes:
|
725
|
+
The full qualified class name of the new protocol class
|
726
|
+
should be as ``{module}.{class_}``.
|
727
|
+
|
728
|
+
The function will register the given protocol class to the
|
729
|
+
:data:`pcapkit.protocols.transport.udp.UDP.__proto__` registry.
|
730
|
+
|
731
|
+
Arguments:
|
732
|
+
code: port number
|
733
|
+
module: module name or module descriptor or a
|
734
|
+
:class:`~pcapkit.protocols.protocol.Protocol` subclass
|
735
|
+
class\_: class name
|
736
|
+
|
737
|
+
"""
|
738
|
+
if isinstance(code, Enum_AppType):
|
739
|
+
code = code.port
|
740
|
+
if isinstance(module, str):
|
741
|
+
module = cast('ModuleDescriptor[Protocol]', ModuleDescriptor(module, class_))
|
742
|
+
|
743
|
+
UDP.register(code, module)
|
744
|
+
logger.info('registered UDP port: %s', code)
|
745
|
+
|
746
|
+
# register protocol to protocol registry
|
747
|
+
if isinstance(module, ModuleDescriptor):
|
748
|
+
module = module.klass
|
749
|
+
register_protocol(module)
|
750
|
+
|
751
|
+
|
752
|
+
###############################################################################
|
753
|
+
# Application Layer Registries
|
754
|
+
###############################################################################
|
755
|
+
|
756
|
+
|
757
|
+
# NOTE: pcapkit.protocols.application.httpv2.HTTPv2.__frame__
|
758
|
+
def register_http_frame(code: 'HTTP_Frame', meth: 'str | tuple[HTTP_FrameParser, HTTP_FrameConstructor]', *,
|
759
|
+
schema: 'Optional[Type[Schema_HTTP_FrameType]]' = None) -> 'None':
|
760
|
+
"""Registered a frame parser.
|
761
|
+
|
762
|
+
The function will register the given frame parser to the
|
763
|
+
:data:`pcapkit.protocols.application.httpv2.HTTP.__frame__` registry.
|
764
|
+
|
765
|
+
Args:
|
766
|
+
code: :class:`HTTP/2 <pcapkit.protocols.application.httpv2.HTTP>` frame type
|
767
|
+
code as in :class:`~pcapkit.const.http.frame.Frame`.
|
768
|
+
meth: Method name or callable to parse and/or construct the frame.
|
769
|
+
schema: :class:`~pcapkit.protocols.schema.schema.Schema` class for the frame.
|
770
|
+
It should be a subclass of :class:`pcapkit.protocols.schema.application.httpv2.FrameType`.
|
771
|
+
|
772
|
+
"""
|
773
|
+
if isinstance(meth, str) and not hasattr(HTTPv2, f'_read_http_{meth}'):
|
774
|
+
raise RegistryError('method must be a frame parser function')
|
775
|
+
|
776
|
+
HTTPv2.register_frame(code, meth)
|
777
|
+
if schema is not None:
|
778
|
+
Schema_HTTP_FrameType.register(code, schema)
|
779
|
+
logger.info('registered HTTP/2 frame parser: %s', code.name)
|
780
|
+
|
781
|
+
|
782
|
+
###############################################################################
|
783
|
+
# Miscellaneous Protocol Registries
|
784
|
+
###############################################################################
|
785
|
+
|
786
|
+
|
787
|
+
# NOTE: pcapkit.protocols.misc.pcapng.PCAPNG.__block__
|
788
|
+
def register_pcapng_block(code: 'PCAPNG_BlockType', meth: 'str | tuple[PCAPNG_BlockParser, PCAPNG_BlockConstructor]', *,
|
789
|
+
schema: 'Optional[Type[Schema_PCAPNG_BlockType]]' = None) -> 'None':
|
790
|
+
"""Registered a block parser.
|
791
|
+
|
792
|
+
The function will register the given block parser to the
|
793
|
+
:data:`pcapkit.protocols.misc.pcapng.PCAPNG.__block__` registry.
|
794
|
+
|
795
|
+
Args:
|
796
|
+
code: :class:`HTTP/2 <pcapkit.protocols.misc.pcapng.PCAPNG>` block type
|
797
|
+
code as in :class:`~pcapkit.const.pcapng.block_type.BlockType`.
|
798
|
+
meth: Method name or callable to parse and/or construct the block.
|
799
|
+
schema: :class:`~pcapkit.protocols.schema.schema.Schema` class for the block.
|
800
|
+
It should be a subclass of :class:`pcapkit.protocols.schema.misc.pcapng.BlockType`.
|
801
|
+
|
802
|
+
"""
|
803
|
+
if isinstance(meth, str) and not hasattr(PCAPNG, f'_read_block_{meth}'):
|
804
|
+
raise RegistryError('method must be a block parser function')
|
805
|
+
|
806
|
+
PCAPNG.register_block(code, meth)
|
807
|
+
if schema is not None:
|
808
|
+
Schema_PCAPNG_BlockType.register(code, schema)
|
809
|
+
logger.info('registered PCAP-NG block parser: %s', code.name)
|
810
|
+
|
811
|
+
|
812
|
+
# NOTE: pcapkit.protocols.misc.pcapng.PCAPNG.__option__
|
813
|
+
def register_pcapng_option(code: 'PCAPNG_OptionType', meth: 'str | tuple[PCAPNG_OptionParser, PCAPNG_OptionConstructor]', *,
|
814
|
+
schema: 'Optional[Type[Schema_PCAPNG_Option]]' = None) -> 'None':
|
815
|
+
"""Registered a option parser.
|
816
|
+
|
817
|
+
The function will register the given option parser to the
|
818
|
+
:data:`pcapkit.protocols.misc.pcapng.PCAPNG.__option__` registry.
|
819
|
+
|
820
|
+
Args:
|
821
|
+
code: :class:`PCAPNG <pcapkit.protocols.misc.pcapng.PCAPNG>` option type
|
822
|
+
code as in :class:`~pcapkit.const.pcapng.option_type.OptionType`.
|
823
|
+
meth: Method name or callable to parse and/or construct the option.
|
824
|
+
schema: :class:`~pcapkit.protocols.schema.schema.Schema` class for the option.
|
825
|
+
It should be a subclass of :class:`pcapkit.protocols.schema.misc.pcapng.Option`.
|
826
|
+
|
827
|
+
"""
|
828
|
+
if isinstance(meth, str) and not hasattr(PCAPNG, f'_read_option_{meth}'):
|
829
|
+
raise RegistryError('method must be a option parser function')
|
830
|
+
|
831
|
+
PCAPNG.register_option(code, meth)
|
832
|
+
if schema is not None:
|
833
|
+
Schema_PCAPNG_Option.register(code, schema)
|
834
|
+
logger.info('registered PCAP-NG option parser: %s', code.name)
|
835
|
+
|
836
|
+
|
837
|
+
# NOTE: pcapkit.protocols.misc.pcapng.PCAPNG.__record__
|
838
|
+
def register_pcapng_record(code: 'PCAPNG_RecordType', meth: 'str | tuple[PCAPNG_RecordParser, PCAPNG_RecordConstructor]', *,
|
839
|
+
schema: 'Optional[Type[Schema_PCAPNG_NameResolutionRecord]]' = None) -> 'None':
|
840
|
+
"""Registered a name resolution record parser.
|
841
|
+
|
842
|
+
The function will register the given name resolution record parser to the
|
843
|
+
:data:`pcapkit.protocols.misc.pcapng.PCAPNG.__record__` registry.
|
844
|
+
|
845
|
+
Args:
|
846
|
+
code: :class:`PCAPNG <pcapkit.protocols.misc.pcapng.PCAPNG>` name
|
847
|
+
resolution record type code as in :class:`~pcapkit.const.pcapng.record_type.RecordType`.
|
848
|
+
meth: Method name or callable to parse and/or construct the name
|
849
|
+
resolution record.
|
850
|
+
schema: :class:`~pcapkit.protocols.schema.schema.Schema` class for the name resolution record.
|
851
|
+
It should be a subclass of :class:`pcapkit.protocols.schema.misc.pcapng.NameResolutionRecord`.
|
852
|
+
|
853
|
+
"""
|
854
|
+
if isinstance(meth, str) and not hasattr(PCAPNG, f'_read_record_{meth}'):
|
855
|
+
raise RegistryError('method must be a name resolution record parser function')
|
856
|
+
|
857
|
+
PCAPNG.register_record(code, meth)
|
858
|
+
if schema is not None:
|
859
|
+
Schema_PCAPNG_NameResolutionRecord.register(code, schema)
|
860
|
+
logger.info('registered PCAP-NG name resolution record parser: %s', code.name)
|
861
|
+
|
862
|
+
|
863
|
+
# NOTE: pcapkit.protocols.misc.pcapng.PCAPNG.__secrets__
|
864
|
+
def register_pcapng_secrets(code: 'PCAPNG_SecretsType', meth: 'str | tuple[PCAPNG_SecretsParser, PCAPNG_SecretsConstructor]', *,
|
865
|
+
schema: 'Optional[Type[Schema_PCAPNG_DSBSecrets]]' = None) -> 'None':
|
866
|
+
"""Registered a decryption secrets parser.
|
867
|
+
|
868
|
+
The function will register the given decryption secrets parser to the
|
869
|
+
:data:`pcapkit.protocols.misc.pcapng.PCAPNG.__secrets__` registry.
|
870
|
+
|
871
|
+
Args:
|
872
|
+
code: :class:`PCAPNG <pcapkit.protocols.misc.pcapng.PCAPNG>` decryption
|
873
|
+
secrets type code as in :class:`~pcapkit.const.pcapng.secrets_type.SecretsType`.
|
874
|
+
meth: Method name or callable to parse and/or construct the decryption secrets.
|
875
|
+
schema: :class:`~pcapkit.protocols.schema.schema.Schema` class for the decryption secrets.
|
876
|
+
It should be a subclass of :class:`pcapkit.protocols.schema.misc.pcapng.DSBSecrets`.
|
877
|
+
|
878
|
+
"""
|
879
|
+
if isinstance(meth, str) and not hasattr(PCAPNG, f'_read_secrets_{meth}'):
|
880
|
+
raise RegistryError('method must be a decryption secrets parser function')
|
881
|
+
|
882
|
+
PCAPNG.register_secrets(code, meth)
|
883
|
+
if schema is not None:
|
884
|
+
Schema_PCAPNG_DSBSecrets.register(code, schema)
|
885
|
+
logger.info('registered PCAP-NG decryption secrets parser: %s', code.name)
|