pypcapkit 1.6.2__pp312-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 +107 -0
- pcapkit/__main__.py +158 -0
- pcapkit/all.py +168 -0
- pcapkit/const/__init__.py +143 -0
- pcapkit/const/arp/__init__.py +35 -0
- pcapkit/const/arp/hardware.py +195 -0
- pcapkit/const/arp/operation.py +145 -0
- pcapkit/const/dccp/__init__.py +58 -0
- pcapkit/const/dccp/ack_vector_state.py +73 -0
- pcapkit/const/dccp/drop_code.py +79 -0
- pcapkit/const/dccp/feature.py +106 -0
- pcapkit/const/dccp/option.py +133 -0
- pcapkit/const/dccp/packet_type.py +103 -0
- pcapkit/const/dccp/reset_code.py +115 -0
- pcapkit/const/esp/__init__.py +49 -0
- pcapkit/const/esp/cipher.py +265 -0
- pcapkit/const/esp/integrity.py +154 -0
- pcapkit/const/ftp/__init__.py +35 -0
- pcapkit/const/ftp/command.py +659 -0
- pcapkit/const/ftp/return_code.py +409 -0
- pcapkit/const/hip/__init__.py +121 -0
- pcapkit/const/hip/certificate.py +91 -0
- pcapkit/const/hip/cipher.py +79 -0
- pcapkit/const/hip/di.py +73 -0
- pcapkit/const/hip/ecdsa_curve.py +73 -0
- pcapkit/const/hip/ecdsa_low_curve.py +70 -0
- pcapkit/const/hip/eddsa_curve.py +79 -0
- pcapkit/const/hip/esp_transform_suite.py +112 -0
- pcapkit/const/hip/group.py +100 -0
- pcapkit/const/hip/hi_algorithm.py +100 -0
- pcapkit/const/hip/hit_suite.py +82 -0
- pcapkit/const/hip/nat_traversal.py +76 -0
- pcapkit/const/hip/notify_message.py +214 -0
- pcapkit/const/hip/packet.py +103 -0
- pcapkit/const/hip/parameter.py +391 -0
- pcapkit/const/hip/registration.py +82 -0
- pcapkit/const/hip/registration_failure.py +98 -0
- pcapkit/const/hip/suite.py +85 -0
- pcapkit/const/hip/transport.py +73 -0
- pcapkit/const/http/__init__.py +52 -0
- pcapkit/const/http/error_code.py +108 -0
- pcapkit/const/http/frame.py +109 -0
- pcapkit/const/http/method.py +329 -0
- pcapkit/const/http/setting.py +110 -0
- pcapkit/const/http/status_code.py +347 -0
- pcapkit/const/icmp/__init__.py +52 -0
- pcapkit/const/icmp/destination_unreachable_code.py +111 -0
- pcapkit/const/icmp/parameter_problem_code.py +70 -0
- pcapkit/const/icmp/time_exceeded_code.py +67 -0
- pcapkit/const/icmp/type.py +179 -0
- pcapkit/const/icmpv6/__init__.py +52 -0
- pcapkit/const/icmpv6/destination_unreachable_code.py +91 -0
- pcapkit/const/icmpv6/parameter_problem_code.py +94 -0
- pcapkit/const/icmpv6/time_exceeded_code.py +67 -0
- pcapkit/const/icmpv6/type.py +209 -0
- pcapkit/const/ieee802_11/__init__.py +52 -0
- pcapkit/const/ieee802_11/control_subtype.py +106 -0
- pcapkit/const/ieee802_11/data_subtype.py +97 -0
- pcapkit/const/ieee802_11/extension_subtype.py +70 -0
- pcapkit/const/ieee802_11/management_subtype.py +109 -0
- pcapkit/const/ieee802_11/type.py +73 -0
- pcapkit/const/igmp/__init__.py +37 -0
- pcapkit/const/igmp/record_type.py +73 -0
- pcapkit/const/igmp/type.py +112 -0
- pcapkit/const/ipv4/__init__.py +79 -0
- pcapkit/const/ipv4/classification_level.py +77 -0
- pcapkit/const/ipv4/option_class.py +69 -0
- pcapkit/const/ipv4/option_number.py +151 -0
- pcapkit/const/ipv4/protection_authority.py +77 -0
- pcapkit/const/ipv4/qs_function.py +65 -0
- pcapkit/const/ipv4/router_alert.py +268 -0
- pcapkit/const/ipv4/tos_del.py +65 -0
- pcapkit/const/ipv4/tos_ecn.py +69 -0
- pcapkit/const/ipv4/tos_pre.py +77 -0
- pcapkit/const/ipv4/tos_rel.py +65 -0
- pcapkit/const/ipv4/tos_thr.py +65 -0
- pcapkit/const/ipv4/ts_flag.py +67 -0
- pcapkit/const/ipv6/__init__.py +70 -0
- pcapkit/const/ipv6/extension_header.py +86 -0
- pcapkit/const/ipv6/option.py +151 -0
- pcapkit/const/ipv6/option_action.py +69 -0
- pcapkit/const/ipv6/qs_function.py +65 -0
- pcapkit/const/ipv6/router_alert.py +280 -0
- pcapkit/const/ipv6/routing.py +94 -0
- pcapkit/const/ipv6/seed_id.py +69 -0
- pcapkit/const/ipv6/smf_dpd_mode.py +65 -0
- pcapkit/const/ipv6/tagger_id.py +76 -0
- pcapkit/const/ipx/__init__.py +37 -0
- pcapkit/const/ipx/packet.py +86 -0
- pcapkit/const/ipx/socket.py +121 -0
- pcapkit/const/l2tp/__init__.py +30 -0
- pcapkit/const/l2tp/type.py +65 -0
- pcapkit/const/linux/__init__.py +28 -0
- pcapkit/const/linux/arphrd.py +91 -0
- pcapkit/const/mh/__init__.py +259 -0
- pcapkit/const/mh/access_type.py +106 -0
- pcapkit/const/mh/ack_status_code.py +85 -0
- pcapkit/const/mh/ani_suboption.py +88 -0
- pcapkit/const/mh/auth_subtype.py +67 -0
- pcapkit/const/mh/binding_ack_flag.py +82 -0
- pcapkit/const/mh/binding_error.py +65 -0
- pcapkit/const/mh/binding_revocation.py +73 -0
- pcapkit/const/mh/binding_update_flag.py +97 -0
- pcapkit/const/mh/cga_extension.py +80 -0
- pcapkit/const/mh/cga_sec.py +71 -0
- pcapkit/const/mh/cga_type.py +82 -0
- pcapkit/const/mh/dhcp_support_mode.py +67 -0
- pcapkit/const/mh/dns_status_code.py +79 -0
- pcapkit/const/mh/dsmip6_tls_packet.py +76 -0
- pcapkit/const/mh/dsmipv6_home_address.py +88 -0
- pcapkit/const/mh/enumerating_algorithm.py +70 -0
- pcapkit/const/mh/fb_ack_status.py +76 -0
- pcapkit/const/mh/fb_action.py +85 -0
- pcapkit/const/mh/fb_indication_trigger.py +79 -0
- pcapkit/const/mh/fb_type.py +73 -0
- pcapkit/const/mh/flow_id_status.py +91 -0
- pcapkit/const/mh/flow_id_suboption.py +85 -0
- pcapkit/const/mh/handoff_type.py +85 -0
- pcapkit/const/mh/handover_ack_flag.py +70 -0
- pcapkit/const/mh/handover_ack_status.py +106 -0
- pcapkit/const/mh/handover_initiate_flag.py +73 -0
- pcapkit/const/mh/handover_initiate_status.py +76 -0
- pcapkit/const/mh/home_address_reply.py +85 -0
- pcapkit/const/mh/lla_code.py +77 -0
- pcapkit/const/mh/lma_mag_suboption.py +73 -0
- pcapkit/const/mh/mn_group_id.py +73 -0
- pcapkit/const/mh/mn_id_subtype.py +91 -0
- pcapkit/const/mh/operator_id.py +77 -0
- pcapkit/const/mh/option.py +274 -0
- pcapkit/const/mh/packet.py +133 -0
- pcapkit/const/mh/qos_attribute.py +103 -0
- pcapkit/const/mh/revocation_status_code.py +97 -0
- pcapkit/const/mh/revocation_trigger.py +100 -0
- pcapkit/const/mh/status_code.py +246 -0
- pcapkit/const/mh/traffic_selector.py +76 -0
- pcapkit/const/mh/upa_status.py +85 -0
- pcapkit/const/mh/upn_reason.py +94 -0
- pcapkit/const/ngap/__init__.py +44 -0
- pcapkit/const/ngap/procedure_code.py +223 -0
- pcapkit/const/ngap/protocol_ie.py +937 -0
- pcapkit/const/ospf/__init__.py +37 -0
- pcapkit/const/ospf/authentication.py +79 -0
- pcapkit/const/ospf/packet.py +85 -0
- pcapkit/const/pcapng/__init__.py +71 -0
- pcapkit/const/pcapng/block_type.py +166 -0
- pcapkit/const/pcapng/filter_type.py +62 -0
- pcapkit/const/pcapng/hash_algorithm.py +73 -0
- pcapkit/const/pcapng/option_type.py +422 -0
- pcapkit/const/pcapng/record_type.py +70 -0
- pcapkit/const/pcapng/secrets_type.py +69 -0
- pcapkit/const/pcapng/tls_key_label.py +89 -0
- pcapkit/const/pcapng/verdict_type.py +67 -0
- pcapkit/const/radiotap/__init__.py +116 -0
- pcapkit/const/radiotap/ampdu_flags.py +85 -0
- pcapkit/const/radiotap/channel_flags.py +94 -0
- pcapkit/const/radiotap/eht_known.py +124 -0
- pcapkit/const/radiotap/field_type.py +165 -0
- pcapkit/const/radiotap/flags.py +85 -0
- pcapkit/const/radiotap/he_data1_known.py +103 -0
- pcapkit/const/radiotap/he_data2_known.py +88 -0
- pcapkit/const/radiotap/he_mu_flags1_known.py +85 -0
- pcapkit/const/radiotap/he_mu_flags2_known.py +67 -0
- pcapkit/const/radiotap/he_mu_other_user_known.py +85 -0
- pcapkit/const/radiotap/lsig_data1.py +67 -0
- pcapkit/const/radiotap/mcs_known.py +85 -0
- pcapkit/const/radiotap/rx_flags.py +64 -0
- pcapkit/const/radiotap/s1g_known.py +85 -0
- pcapkit/const/radiotap/timestamp_flags.py +67 -0
- pcapkit/const/radiotap/tx_flags.py +82 -0
- pcapkit/const/radiotap/usig_common_known.py +85 -0
- pcapkit/const/radiotap/vht_coding.py +73 -0
- pcapkit/const/radiotap/vht_flags.py +84 -0
- pcapkit/const/radiotap/vht_known.py +90 -0
- pcapkit/const/reg/__init__.py +54 -0
- pcapkit/const/reg/apptype/__init__.py +164 -0
- pcapkit/const/reg/apptype/apptype.py +5233 -0
- pcapkit/const/reg/apptype/dccp.py +112 -0
- pcapkit/const/reg/apptype/sctp.py +432 -0
- pcapkit/const/reg/apptype/tcp.py +25154 -0
- pcapkit/const/reg/apptype/udp.py +24563 -0
- pcapkit/const/reg/ethertype.py +740 -0
- pcapkit/const/reg/linktype.py +811 -0
- pcapkit/const/reg/transtype.py +552 -0
- pcapkit/const/sctp/__init__.py +49 -0
- pcapkit/const/sctp/cause_code.py +146 -0
- pcapkit/const/sctp/chunk.py +164 -0
- pcapkit/const/sctp/parameter.py +170 -0
- pcapkit/const/sctp/payload_protocol_identifier.py +325 -0
- pcapkit/const/sslv2/__init__.py +37 -0
- pcapkit/const/sslv2/handshake_type.py +88 -0
- pcapkit/const/sslv2/version.py +64 -0
- pcapkit/const/tcp/__init__.py +47 -0
- pcapkit/const/tcp/checksum.py +69 -0
- pcapkit/const/tcp/flags.py +96 -0
- pcapkit/const/tcp/mp_tcp_option.py +95 -0
- pcapkit/const/tcp/option.py +210 -0
- pcapkit/const/tls/__init__.py +44 -0
- pcapkit/const/tls/content_type.py +99 -0
- pcapkit/const/tls/extension_type.py +382 -0
- pcapkit/const/tls/handshake_type.py +154 -0
- pcapkit/const/vlan/__init__.py +32 -0
- pcapkit/const/vlan/priority_level.py +85 -0
- pcapkit/corekit/__init__.py +64 -0
- pcapkit/corekit/checksum/__init__.py +24 -0
- pcapkit/corekit/checksum/internet.py +253 -0
- pcapkit/corekit/context.py +248 -0
- pcapkit/corekit/decorators.py +328 -0
- pcapkit/corekit/enum.py +742 -0
- pcapkit/corekit/fields/__init__.py +46 -0
- pcapkit/corekit/fields/collections.py +646 -0
- pcapkit/corekit/fields/field.py +643 -0
- pcapkit/corekit/fields/ipaddress.py +582 -0
- pcapkit/corekit/fields/misc.py +843 -0
- pcapkit/corekit/fields/numbers.py +1279 -0
- pcapkit/corekit/fields/strings.py +445 -0
- pcapkit/corekit/infoclass.py +1231 -0
- pcapkit/corekit/io.py +980 -0
- pcapkit/corekit/module.py +133 -0
- pcapkit/corekit/multidict.py +676 -0
- pcapkit/corekit/packet.py +179 -0
- pcapkit/corekit/protochain.py +266 -0
- pcapkit/corekit/schema/__init__.py +20 -0
- pcapkit/corekit/schema/byteorder.py +89 -0
- pcapkit/corekit/schema/ipaddress.py +210 -0
- pcapkit/corekit/schema/jumbogram.py +66 -0
- pcapkit/corekit/schema/padding.py +50 -0
- pcapkit/corekit/schema/shortread.py +150 -0
- pcapkit/corekit/sentinels.py +597 -0
- pcapkit/corekit/version.py +40 -0
- pcapkit/dumpkit/__init__.py +14 -0
- pcapkit/dumpkit/common.py +778 -0
- pcapkit/dumpkit/null.py +72 -0
- pcapkit/dumpkit/pcap.py +292 -0
- pcapkit/foundation/__init__.py +63 -0
- pcapkit/foundation/analysis/__init__.py +27 -0
- pcapkit/foundation/analysis/dtls.py +61 -0
- pcapkit/foundation/analysis/ip.py +88 -0
- pcapkit/foundation/analysis/tcp.py +87 -0
- pcapkit/foundation/engines/__init__.py +35 -0
- pcapkit/foundation/engines/_pcap_backend.py +358 -0
- pcapkit/foundation/engines/dpkt.py +680 -0
- pcapkit/foundation/engines/engine.py +318 -0
- pcapkit/foundation/engines/pcap.py +259 -0
- pcapkit/foundation/engines/pcap_ct.py +469 -0
- pcapkit/foundation/engines/pcapng.py +513 -0
- pcapkit/foundation/engines/pypcap.py +386 -0
- pcapkit/foundation/engines/pypcapfile.py +477 -0
- pcapkit/foundation/engines/pyshark.py +374 -0
- pcapkit/foundation/engines/scapy.py +451 -0
- pcapkit/foundation/extraction.py +1833 -0
- pcapkit/foundation/reassembly/__init__.py +55 -0
- pcapkit/foundation/reassembly/data/__init__.py +43 -0
- pcapkit/foundation/reassembly/data/data.py +300 -0
- pcapkit/foundation/reassembly/data/dtls.py +186 -0
- pcapkit/foundation/reassembly/data/ip.py +203 -0
- pcapkit/foundation/reassembly/data/tcp.py +296 -0
- pcapkit/foundation/reassembly/dtls.py +340 -0
- pcapkit/foundation/reassembly/ip.py +639 -0
- pcapkit/foundation/reassembly/ipv4.py +80 -0
- pcapkit/foundation/reassembly/ipv6.py +206 -0
- pcapkit/foundation/reassembly/reassembly.py +605 -0
- pcapkit/foundation/reassembly/tcp.py +870 -0
- pcapkit/foundation/registry/__init__.py +56 -0
- pcapkit/foundation/registry/foundation.py +362 -0
- pcapkit/foundation/registry/protocols/__init__.py +67 -0
- pcapkit/foundation/registry/protocols/application.py +119 -0
- pcapkit/foundation/registry/protocols/internet.py +506 -0
- pcapkit/foundation/registry/protocols/link.py +378 -0
- pcapkit/foundation/registry/protocols/misc.py +352 -0
- pcapkit/foundation/registry/protocols/protocol.py +519 -0
- pcapkit/foundation/registry/protocols/transport.py +647 -0
- pcapkit/foundation/traceflow/__init__.py +45 -0
- pcapkit/foundation/traceflow/data/__init__.py +17 -0
- pcapkit/foundation/traceflow/data/data.py +193 -0
- pcapkit/foundation/traceflow/data/tcp.py +212 -0
- pcapkit/foundation/traceflow/tcp.py +581 -0
- pcapkit/foundation/traceflow/traceflow.py +593 -0
- pcapkit/interface/__init__.py +23 -0
- pcapkit/interface/core.py +265 -0
- pcapkit/interface/misc.py +186 -0
- pcapkit/interface/registry.py +116 -0
- pcapkit/protocols/__init__.py +95 -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/xmpp.py +0 -0
- pcapkit/protocols/application/__init__.py +79 -0
- pcapkit/protocols/application/application.py +189 -0
- pcapkit/protocols/application/drarp/__init__.py +14 -0
- pcapkit/protocols/application/drarp/protocol.py +53 -0
- pcapkit/protocols/application/dtls/__init__.py +30 -0
- pcapkit/protocols/application/dtls/data.py +150 -0
- pcapkit/protocols/application/dtls/protocol.py +1137 -0
- pcapkit/protocols/application/dtls/schema.py +157 -0
- pcapkit/protocols/application/ftp/__init__.py +27 -0
- pcapkit/protocols/application/ftp/data.py +72 -0
- pcapkit/protocols/application/ftp/protocol.py +410 -0
- pcapkit/protocols/application/ftp/schema.py +21 -0
- pcapkit/protocols/application/ftp_data/__init__.py +14 -0
- pcapkit/protocols/application/ftp_data/protocol.py +97 -0
- pcapkit/protocols/application/http/__init__.py +14 -0
- pcapkit/protocols/application/http/protocol.py +773 -0
- pcapkit/protocols/application/httpv1/__init__.py +28 -0
- pcapkit/protocols/application/httpv1/data.py +98 -0
- pcapkit/protocols/application/httpv1/protocol.py +610 -0
- pcapkit/protocols/application/httpv1/schema.py +29 -0
- pcapkit/protocols/application/httpv2/__init__.py +61 -0
- pcapkit/protocols/application/httpv2/data.py +347 -0
- pcapkit/protocols/application/httpv2/protocol.py +1724 -0
- pcapkit/protocols/application/httpv2/schema.py +430 -0
- pcapkit/protocols/application/ngap/__init__.py +29 -0
- pcapkit/protocols/application/ngap/data.py +124 -0
- pcapkit/protocols/application/ngap/protocol.py +578 -0
- pcapkit/protocols/application/ngap/schema.py +29 -0
- pcapkit/protocols/application/ospf/__init__.py +29 -0
- pcapkit/protocols/application/ospf/data.py +79 -0
- pcapkit/protocols/application/ospf/protocol.py +544 -0
- pcapkit/protocols/application/ospf/schema.py +109 -0
- pcapkit/protocols/application/rarp/__init__.py +14 -0
- pcapkit/protocols/application/rarp/protocol.py +111 -0
- pcapkit/protocols/application/ssl/__init__.py +43 -0
- pcapkit/protocols/application/ssl/data.py +322 -0
- pcapkit/protocols/application/ssl/protocol.py +1522 -0
- pcapkit/protocols/application/sslv2/__init__.py +32 -0
- pcapkit/protocols/application/sslv2/data.py +93 -0
- pcapkit/protocols/application/sslv2/protocol.py +543 -0
- pcapkit/protocols/application/sslv2/schema.py +304 -0
- pcapkit/protocols/application/sslv3/__init__.py +14 -0
- pcapkit/protocols/application/sslv3/protocol.py +51 -0
- pcapkit/protocols/application/tls/__init__.py +25 -0
- pcapkit/protocols/application/tls/data.py +40 -0
- pcapkit/protocols/application/tls/protocol.py +561 -0
- pcapkit/protocols/application/tls/schema.py +44 -0
- pcapkit/protocols/data.py +76 -0
- pcapkit/protocols/internet/NotImplemented/ecn.py +0 -0
- pcapkit/protocols/internet/NotImplemented/shim6.py +0 -0
- pcapkit/protocols/internet/__init__.py +87 -0
- pcapkit/protocols/internet/ah/__init__.py +25 -0
- pcapkit/protocols/internet/ah/data.py +39 -0
- pcapkit/protocols/internet/ah/protocol.py +343 -0
- pcapkit/protocols/internet/ah/schema.py +57 -0
- pcapkit/protocols/internet/esp/__init__.py +25 -0
- pcapkit/protocols/internet/esp/data.py +71 -0
- pcapkit/protocols/internet/esp/protocol.py +1509 -0
- pcapkit/protocols/internet/esp/schema.py +46 -0
- pcapkit/protocols/internet/hip/__init__.py +169 -0
- pcapkit/protocols/internet/hip/data.py +1109 -0
- pcapkit/protocols/internet/hip/protocol.py +5697 -0
- pcapkit/protocols/internet/hip/schema.py +1654 -0
- pcapkit/protocols/internet/hopopt/__init__.py +80 -0
- pcapkit/protocols/internet/hopopt/data.py +445 -0
- pcapkit/protocols/internet/hopopt/protocol.py +2346 -0
- pcapkit/protocols/internet/hopopt/schema.py +686 -0
- pcapkit/protocols/internet/icmp/__init__.py +14 -0
- pcapkit/protocols/internet/icmp/protocol.py +201 -0
- pcapkit/protocols/internet/icmpv4/__init__.py +38 -0
- pcapkit/protocols/internet/icmpv4/data.py +153 -0
- pcapkit/protocols/internet/icmpv4/protocol.py +652 -0
- pcapkit/protocols/internet/icmpv4/schema.py +135 -0
- pcapkit/protocols/internet/icmpv6/__init__.py +40 -0
- pcapkit/protocols/internet/icmpv6/data.py +174 -0
- pcapkit/protocols/internet/icmpv6/protocol.py +735 -0
- pcapkit/protocols/internet/icmpv6/schema.py +144 -0
- pcapkit/protocols/internet/igmp/__init__.py +25 -0
- pcapkit/protocols/internet/igmp/data.py +59 -0
- pcapkit/protocols/internet/igmp/protocol.py +491 -0
- pcapkit/protocols/internet/igmp/schema.py +54 -0
- pcapkit/protocols/internet/igmpv1/__init__.py +14 -0
- pcapkit/protocols/internet/igmpv1/protocol.py +63 -0
- pcapkit/protocols/internet/igmpv2/__init__.py +14 -0
- pcapkit/protocols/internet/igmpv2/protocol.py +65 -0
- pcapkit/protocols/internet/igmpv3/__init__.py +32 -0
- pcapkit/protocols/internet/igmpv3/data.py +150 -0
- pcapkit/protocols/internet/igmpv3/protocol.py +587 -0
- pcapkit/protocols/internet/igmpv3/schema.py +373 -0
- pcapkit/protocols/internet/internet.py +566 -0
- pcapkit/protocols/internet/ip/__init__.py +14 -0
- pcapkit/protocols/internet/ip/protocol.py +205 -0
- pcapkit/protocols/internet/ipsec/__init__.py +14 -0
- pcapkit/protocols/internet/ipsec/protocol.py +48 -0
- pcapkit/protocols/internet/ipv4/__init__.py +68 -0
- pcapkit/protocols/internet/ipv4/data.py +470 -0
- pcapkit/protocols/internet/ipv4/protocol.py +2293 -0
- pcapkit/protocols/internet/ipv4/schema.py +747 -0
- pcapkit/protocols/internet/ipv6/__init__.py +25 -0
- pcapkit/protocols/internet/ipv6/data.py +83 -0
- pcapkit/protocols/internet/ipv6/protocol.py +731 -0
- pcapkit/protocols/internet/ipv6/schema.py +176 -0
- pcapkit/protocols/internet/ipv6_ext/__init__.py +25 -0
- pcapkit/protocols/internet/ipv6_ext/data.py +52 -0
- pcapkit/protocols/internet/ipv6_ext/protocol.py +718 -0
- pcapkit/protocols/internet/ipv6_ext/schema.py +397 -0
- pcapkit/protocols/internet/ipv6_frag/__init__.py +25 -0
- pcapkit/protocols/internet/ipv6_frag/data.py +41 -0
- pcapkit/protocols/internet/ipv6_frag/protocol.py +320 -0
- pcapkit/protocols/internet/ipv6_frag/schema.py +51 -0
- pcapkit/protocols/internet/ipv6_opts/__init__.py +83 -0
- pcapkit/protocols/internet/ipv6_opts/data.py +462 -0
- pcapkit/protocols/internet/ipv6_opts/protocol.py +2335 -0
- pcapkit/protocols/internet/ipv6_opts/schema.py +695 -0
- pcapkit/protocols/internet/ipv6_route/__init__.py +34 -0
- pcapkit/protocols/internet/ipv6_route/data.py +113 -0
- pcapkit/protocols/internet/ipv6_route/protocol.py +936 -0
- pcapkit/protocols/internet/ipv6_route/schema.py +299 -0
- pcapkit/protocols/internet/ipx/__init__.py +26 -0
- pcapkit/protocols/internet/ipx/data.py +59 -0
- pcapkit/protocols/internet/ipx/protocol.py +387 -0
- pcapkit/protocols/internet/ipx/schema.py +53 -0
- pcapkit/protocols/internet/mh/__init__.py +433 -0
- pcapkit/protocols/internet/mh/data.py +2464 -0
- pcapkit/protocols/internet/mh/protocol.py +11753 -0
- pcapkit/protocols/internet/mh/schema.py +3367 -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 +80 -0
- pcapkit/protocols/link/arp/__init__.py +27 -0
- pcapkit/protocols/link/arp/data.py +73 -0
- pcapkit/protocols/link/arp/protocol.py +513 -0
- pcapkit/protocols/link/arp/schema.py +49 -0
- pcapkit/protocols/link/c_tag/__init__.py +14 -0
- pcapkit/protocols/link/c_tag/protocol.py +99 -0
- pcapkit/protocols/link/ethernet/__init__.py +25 -0
- pcapkit/protocols/link/ethernet/data.py +27 -0
- pcapkit/protocols/link/ethernet/protocol.py +221 -0
- pcapkit/protocols/link/ethernet/schema.py +72 -0
- pcapkit/protocols/link/frad/__init__.py +25 -0
- pcapkit/protocols/link/frad/data.py +47 -0
- pcapkit/protocols/link/frad/protocol.py +470 -0
- pcapkit/protocols/link/frad/schema.py +112 -0
- pcapkit/protocols/link/gre/__init__.py +25 -0
- pcapkit/protocols/link/gre/data.py +64 -0
- pcapkit/protocols/link/gre/protocol.py +396 -0
- pcapkit/protocols/link/gre/schema.py +91 -0
- pcapkit/protocols/link/ieee802_11/__init__.py +30 -0
- pcapkit/protocols/link/ieee802_11/data.py +171 -0
- pcapkit/protocols/link/ieee802_11/protocol.py +612 -0
- pcapkit/protocols/link/ieee802_11/schema.py +163 -0
- pcapkit/protocols/link/inarp/__init__.py +14 -0
- pcapkit/protocols/link/inarp/protocol.py +55 -0
- pcapkit/protocols/link/l2tp/__init__.py +26 -0
- pcapkit/protocols/link/l2tp/data.py +72 -0
- pcapkit/protocols/link/l2tp/protocol.py +285 -0
- pcapkit/protocols/link/l2tp/schema.py +122 -0
- pcapkit/protocols/link/l2tpv2/__init__.py +14 -0
- pcapkit/protocols/link/l2tpv2/protocol.py +440 -0
- pcapkit/protocols/link/link.py +226 -0
- pcapkit/protocols/link/linux_sll/__init__.py +14 -0
- pcapkit/protocols/link/linux_sll/protocol.py +421 -0
- pcapkit/protocols/link/linux_sll1/__init__.py +25 -0
- pcapkit/protocols/link/linux_sll1/data.py +41 -0
- pcapkit/protocols/link/linux_sll1/protocol.py +247 -0
- pcapkit/protocols/link/linux_sll1/schema.py +46 -0
- pcapkit/protocols/link/linux_sll2/__init__.py +25 -0
- pcapkit/protocols/link/linux_sll2/data.py +47 -0
- pcapkit/protocols/link/linux_sll2/protocol.py +257 -0
- pcapkit/protocols/link/linux_sll2/schema.py +52 -0
- pcapkit/protocols/link/loopback/__init__.py +25 -0
- pcapkit/protocols/link/loopback/data.py +25 -0
- pcapkit/protocols/link/loopback/protocol.py +334 -0
- pcapkit/protocols/link/loopback/schema.py +33 -0
- pcapkit/protocols/link/netlink/__init__.py +25 -0
- pcapkit/protocols/link/netlink/data.py +40 -0
- pcapkit/protocols/link/netlink/protocol.py +390 -0
- pcapkit/protocols/link/netlink/schema.py +44 -0
- pcapkit/protocols/link/radiotap/__init__.py +103 -0
- pcapkit/protocols/link/radiotap/data.py +768 -0
- pcapkit/protocols/link/radiotap/protocol.py +2264 -0
- pcapkit/protocols/link/radiotap/schema.py +662 -0
- pcapkit/protocols/link/s_tag/__init__.py +14 -0
- pcapkit/protocols/link/s_tag/protocol.py +102 -0
- pcapkit/protocols/link/vlan/__init__.py +27 -0
- pcapkit/protocols/link/vlan/data.py +47 -0
- pcapkit/protocols/link/vlan/protocol.py +269 -0
- pcapkit/protocols/link/vlan/schema.py +77 -0
- pcapkit/protocols/misc/__init__.py +60 -0
- pcapkit/protocols/misc/checksum/__init__.py +28 -0
- pcapkit/protocols/misc/checksum/ip_pseudo/__init__.py +25 -0
- pcapkit/protocols/misc/checksum/ip_pseudo/data.py +41 -0
- pcapkit/protocols/misc/checksum/ip_pseudo/protocol.py +692 -0
- pcapkit/protocols/misc/checksum/ip_pseudo/schema.py +118 -0
- pcapkit/protocols/misc/no_payload/__init__.py +25 -0
- pcapkit/protocols/misc/no_payload/data.py +17 -0
- pcapkit/protocols/misc/no_payload/protocol.py +164 -0
- pcapkit/protocols/misc/no_payload/schema.py +17 -0
- pcapkit/protocols/misc/pcap/__init__.py +30 -0
- pcapkit/protocols/misc/pcap/frame/__init__.py +26 -0
- pcapkit/protocols/misc/pcap/frame/data.py +62 -0
- pcapkit/protocols/misc/pcap/frame/protocol.py +673 -0
- pcapkit/protocols/misc/pcap/frame/schema.py +47 -0
- pcapkit/protocols/misc/pcap/header/__init__.py +26 -0
- pcapkit/protocols/misc/pcap/header/data.py +52 -0
- pcapkit/protocols/misc/pcap/header/protocol.py +391 -0
- pcapkit/protocols/misc/pcap/header/schema.py +103 -0
- pcapkit/protocols/misc/pcapng/__init__.py +160 -0
- pcapkit/protocols/misc/pcapng/data.py +1102 -0
- pcapkit/protocols/misc/pcapng/protocol.py +6960 -0
- pcapkit/protocols/misc/pcapng/schema.py +2825 -0
- pcapkit/protocols/misc/raw/__init__.py +25 -0
- pcapkit/protocols/misc/raw/data.py +35 -0
- pcapkit/protocols/misc/raw/protocol.py +188 -0
- pcapkit/protocols/misc/raw/schema.py +24 -0
- pcapkit/protocols/protocol.py +3145 -0
- pcapkit/protocols/schema.py +1295 -0
- pcapkit/protocols/transport/NotImplemented/rsvp.py +0 -0
- pcapkit/protocols/transport/__init__.py +47 -0
- pcapkit/protocols/transport/dccp/__init__.py +57 -0
- pcapkit/protocols/transport/dccp/data.py +275 -0
- pcapkit/protocols/transport/dccp/protocol.py +1525 -0
- pcapkit/protocols/transport/dccp/schema.py +381 -0
- pcapkit/protocols/transport/sctp/__init__.py +147 -0
- pcapkit/protocols/transport/sctp/data.py +633 -0
- pcapkit/protocols/transport/sctp/protocol.py +3937 -0
- pcapkit/protocols/transport/sctp/schema.py +1007 -0
- pcapkit/protocols/transport/tcp/__init__.py +108 -0
- pcapkit/protocols/transport/tcp/data.py +637 -0
- pcapkit/protocols/transport/tcp/protocol.py +3640 -0
- pcapkit/protocols/transport/tcp/schema.py +1131 -0
- pcapkit/protocols/transport/transport.py +371 -0
- pcapkit/protocols/transport/udp/__init__.py +25 -0
- pcapkit/protocols/transport/udp/data.py +38 -0
- pcapkit/protocols/transport/udp/protocol.py +384 -0
- pcapkit/protocols/transport/udp/schema.py +44 -0
- pcapkit/py.typed +0 -0
- pcapkit/toolkit/__init__.py +88 -0
- pcapkit/toolkit/dpkt.py +909 -0
- pcapkit/toolkit/pcap.py +510 -0
- pcapkit/toolkit/pcap_ct.py +160 -0
- pcapkit/toolkit/pcapng.py +287 -0
- pcapkit/toolkit/pypcap.py +158 -0
- pcapkit/toolkit/pypcapfile.py +917 -0
- pcapkit/toolkit/pyshark.py +628 -0
- pcapkit/toolkit/scapy.py +761 -0
- pcapkit/utilities/__init__.py +41 -0
- pcapkit/utilities/chardet.py +64 -0
- pcapkit/utilities/compat.py +173 -0
- pcapkit/utilities/config.py +446 -0
- pcapkit/utilities/contextvars.py +57 -0
- pcapkit/utilities/datetime.py +117 -0
- pcapkit/utilities/exceptions.py +845 -0
- pcapkit/utilities/importlib.py +123 -0
- pcapkit/utilities/inspect.py +55 -0
- pcapkit/utilities/logging.py +395 -0
- pcapkit/utilities/pickle.py +181 -0
- pcapkit/utilities/warnings.py +538 -0
- pcapkit/vendor/__init__.py +220 -0
- pcapkit/vendor/__main__.py +253 -0
- pcapkit/vendor/arp/__init__.py +27 -0
- pcapkit/vendor/arp/hardware.py +29 -0
- pcapkit/vendor/arp/operation.py +29 -0
- pcapkit/vendor/dccp/__init__.py +44 -0
- pcapkit/vendor/dccp/ack_vector_state.py +29 -0
- pcapkit/vendor/dccp/drop_code.py +29 -0
- pcapkit/vendor/dccp/feature.py +29 -0
- pcapkit/vendor/dccp/option.py +29 -0
- pcapkit/vendor/dccp/packet_type.py +29 -0
- pcapkit/vendor/dccp/reset_code.py +29 -0
- pcapkit/vendor/default.py +823 -0
- pcapkit/vendor/esp/__init__.py +32 -0
- pcapkit/vendor/esp/cipher.py +114 -0
- pcapkit/vendor/esp/integrity.py +111 -0
- pcapkit/vendor/ftp/__init__.py +27 -0
- pcapkit/vendor/ftp/command.py +577 -0
- pcapkit/vendor/ftp/return_code.py +363 -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 +94 -0
- pcapkit/vendor/http/frame.py +91 -0
- pcapkit/vendor/http/method.py +309 -0
- pcapkit/vendor/http/setting.py +93 -0
- pcapkit/vendor/http/status_code.py +233 -0
- pcapkit/vendor/icmp/__init__.py +40 -0
- pcapkit/vendor/icmp/destination_unreachable_code.py +80 -0
- pcapkit/vendor/icmp/parameter_problem_code.py +80 -0
- pcapkit/vendor/icmp/time_exceeded_code.py +80 -0
- pcapkit/vendor/icmp/type.py +78 -0
- pcapkit/vendor/icmpv6/__init__.py +40 -0
- pcapkit/vendor/icmpv6/destination_unreachable_code.py +80 -0
- pcapkit/vendor/icmpv6/parameter_problem_code.py +80 -0
- pcapkit/vendor/icmpv6/time_exceeded_code.py +73 -0
- pcapkit/vendor/icmpv6/type.py +78 -0
- pcapkit/vendor/ieee802_11/__init__.py +54 -0
- pcapkit/vendor/ieee802_11/control_subtype.py +107 -0
- pcapkit/vendor/ieee802_11/data_subtype.py +106 -0
- pcapkit/vendor/ieee802_11/extension_subtype.py +95 -0
- pcapkit/vendor/ieee802_11/management_subtype.py +102 -0
- pcapkit/vendor/ieee802_11/type.py +90 -0
- pcapkit/vendor/igmp/__init__.py +27 -0
- pcapkit/vendor/igmp/record_type.py +88 -0
- pcapkit/vendor/igmp/type.py +77 -0
- pcapkit/vendor/ipv4/__init__.py +59 -0
- pcapkit/vendor/ipv4/classification_level.py +90 -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 +94 -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 +78 -0
- pcapkit/vendor/ipv4/ts_flag.py +79 -0
- pcapkit/vendor/ipv6/__init__.py +53 -0
- pcapkit/vendor/ipv6/extension_header.py +220 -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 +39 -0
- pcapkit/vendor/ipx/packet.py +149 -0
- pcapkit/vendor/ipx/socket.py +240 -0
- pcapkit/vendor/l2tp/__init__.py +21 -0
- pcapkit/vendor/l2tp/type.py +79 -0
- pcapkit/vendor/linux/__init__.py +21 -0
- pcapkit/vendor/linux/arphrd.py +100 -0
- pcapkit/vendor/mh/__init__.py +206 -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 +164 -0
- pcapkit/vendor/mh/binding_error.py +78 -0
- pcapkit/vendor/mh/binding_revocation.py +87 -0
- pcapkit/vendor/mh/binding_update_flag.py +163 -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 +159 -0
- pcapkit/vendor/mh/handover_ack_status.py +87 -0
- pcapkit/vendor/mh/handover_initiate_flag.py +159 -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/ngap/__init__.py +31 -0
- pcapkit/vendor/ngap/procedure_code.py +233 -0
- pcapkit/vendor/ngap/protocol_ie.py +201 -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 +55 -0
- pcapkit/vendor/pcapng/block_type.py +102 -0
- pcapkit/vendor/pcapng/filter_type.py +77 -0
- pcapkit/vendor/pcapng/hash_algorithm.py +82 -0
- pcapkit/vendor/pcapng/option_type.py +477 -0
- pcapkit/vendor/pcapng/record_type.py +81 -0
- pcapkit/vendor/pcapng/secrets_type.py +80 -0
- pcapkit/vendor/pcapng/tls_key_label.py +180 -0
- pcapkit/vendor/pcapng/verdict_type.py +79 -0
- pcapkit/vendor/radiotap/__init__.py +86 -0
- pcapkit/vendor/radiotap/ampdu_flags.py +46 -0
- pcapkit/vendor/radiotap/channel_flags.py +51 -0
- pcapkit/vendor/radiotap/eht_known.py +59 -0
- pcapkit/vendor/radiotap/field_type.py +151 -0
- pcapkit/vendor/radiotap/flags.py +307 -0
- pcapkit/vendor/radiotap/he_data1_known.py +54 -0
- pcapkit/vendor/radiotap/he_data2_known.py +49 -0
- pcapkit/vendor/radiotap/he_mu_flags1_known.py +48 -0
- pcapkit/vendor/radiotap/he_mu_flags2_known.py +42 -0
- pcapkit/vendor/radiotap/he_mu_other_user_known.py +38 -0
- pcapkit/vendor/radiotap/lsig_data1.py +40 -0
- pcapkit/vendor/radiotap/mcs_known.py +48 -0
- pcapkit/vendor/radiotap/rx_flags.py +39 -0
- pcapkit/vendor/radiotap/s1g_known.py +46 -0
- pcapkit/vendor/radiotap/timestamp_flags.py +40 -0
- pcapkit/vendor/radiotap/tx_flags.py +44 -0
- pcapkit/vendor/radiotap/usig_common_known.py +48 -0
- pcapkit/vendor/radiotap/vht_coding.py +42 -0
- pcapkit/vendor/radiotap/vht_flags.py +44 -0
- pcapkit/vendor/radiotap/vht_known.py +47 -0
- pcapkit/vendor/reg/__init__.py +47 -0
- pcapkit/vendor/reg/apptype/__init__.py +36 -0
- pcapkit/vendor/reg/apptype/apptype.py +1320 -0
- pcapkit/vendor/reg/apptype/dccp.py +27 -0
- pcapkit/vendor/reg/apptype/sctp.py +27 -0
- pcapkit/vendor/reg/apptype/tcp.py +27 -0
- pcapkit/vendor/reg/apptype/udp.py +27 -0
- pcapkit/vendor/reg/ethertype.py +175 -0
- pcapkit/vendor/reg/linktype.py +210 -0
- pcapkit/vendor/reg/transtype.py +116 -0
- pcapkit/vendor/sctp/__init__.py +37 -0
- pcapkit/vendor/sctp/cause_code.py +29 -0
- pcapkit/vendor/sctp/chunk.py +29 -0
- pcapkit/vendor/sctp/parameter.py +29 -0
- pcapkit/vendor/sctp/payload_protocol_identifier.py +34 -0
- pcapkit/vendor/sslv2/__init__.py +24 -0
- pcapkit/vendor/sslv2/handshake_type.py +100 -0
- pcapkit/vendor/sslv2/version.py +95 -0
- pcapkit/vendor/tcp/__init__.py +35 -0
- pcapkit/vendor/tcp/checksum.py +80 -0
- pcapkit/vendor/tcp/flags.py +180 -0
- pcapkit/vendor/tcp/mp_tcp_option.py +90 -0
- pcapkit/vendor/tcp/option.py +103 -0
- pcapkit/vendor/tls/__init__.py +30 -0
- pcapkit/vendor/tls/content_type.py +142 -0
- pcapkit/vendor/tls/extension_type.py +151 -0
- pcapkit/vendor/tls/handshake_type.py +154 -0
- pcapkit/vendor/vlan/__init__.py +23 -0
- pcapkit/vendor/vlan/priority_level.py +97 -0
- pypcapkit-1.6.2.dist-info/METADATA +199 -0
- pypcapkit-1.6.2.dist-info/RECORD +770 -0
- pypcapkit-1.6.2.dist-info/WHEEL +5 -0
- pypcapkit-1.6.2.dist-info/entry_points.txt +3 -0
- pypcapkit-1.6.2.dist-info/licenses/LICENSE +29 -0
- pypcapkit-1.6.2.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,519 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""Protocol Base Registries
|
|
3
|
+
==============================
|
|
4
|
+
|
|
5
|
+
.. module:: pcapkit.foundation.registry.protocols.protocol
|
|
6
|
+
|
|
7
|
+
This module provides the protocol registries the per-layer modules beside it
|
|
8
|
+
build on: :func:`register_protocol` for the by-name registry
|
|
9
|
+
:attr:`ProtocolBase.__registry__ <pcapkit.protocols.protocol.ProtocolBase.__registry__>`,
|
|
10
|
+
:func:`register_protocol_code` for the
|
|
11
|
+
next-layer registries a ``code`` names, and the validation and by-name
|
|
12
|
+
bookkeeping every registrar shares.
|
|
13
|
+
|
|
14
|
+
.. versionadded:: 1.6.0
|
|
15
|
+
|
|
16
|
+
Moved here from the single :file:`pcapkit/foundation/registry/protocols.py`
|
|
17
|
+
module. The :mod:`pcapkit.foundation.registry.protocols` package exports
|
|
18
|
+
this module's public functions (:issue:`2578`).
|
|
19
|
+
|
|
20
|
+
"""
|
|
21
|
+
import collections.abc
|
|
22
|
+
import enum
|
|
23
|
+
import sys
|
|
24
|
+
import threading
|
|
25
|
+
from typing import TYPE_CHECKING, cast
|
|
26
|
+
|
|
27
|
+
import aenum
|
|
28
|
+
|
|
29
|
+
from pcapkit.corekit.module import ModuleDescriptor
|
|
30
|
+
from pcapkit.corekit.sentinels import MISSING
|
|
31
|
+
from pcapkit.protocols.protocol import ProtocolBase
|
|
32
|
+
from pcapkit.utilities.exceptions import RegistryError
|
|
33
|
+
from pcapkit.utilities.logging import get_logger
|
|
34
|
+
|
|
35
|
+
if TYPE_CHECKING:
|
|
36
|
+
from typing import Any, Iterator, Optional, Type
|
|
37
|
+
|
|
38
|
+
__all__ = [
|
|
39
|
+
'register_protocol',
|
|
40
|
+
'register_protocol_code',
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
#: logging.Logger: Module-level logger, a child of the package-wide
|
|
44
|
+
#: :data:`pcapkit.utilities.logging.logger`.
|
|
45
|
+
logger = get_logger(__name__)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
# NOTE: pcapkit.protocols.protocol.ProtocolBase.__registry__
|
|
49
|
+
def register_protocol(protocol: 'Type[ProtocolBase]') -> 'None':
|
|
50
|
+
"""Register a protocol class.
|
|
51
|
+
|
|
52
|
+
The protocol class must be a subclass of
|
|
53
|
+
:class:`~pcapkit.protocols.protocol.ProtocolBase`, and will be registered to
|
|
54
|
+
the by-name registry :attr:`ProtocolBase.__registry__
|
|
55
|
+
<pcapkit.protocols.protocol.ProtocolBase.__registry__>` through
|
|
56
|
+
:meth:`ProtocolBase.register_protocol
|
|
57
|
+
<pcapkit.protocols.protocol.ProtocolBase.register_protocol>`, replacing the
|
|
58
|
+
entry its name holds.
|
|
59
|
+
|
|
60
|
+
The registry is keyed on ``protocol.__name__.upper()``, which nothing makes
|
|
61
|
+
unique: two protocol classes of the same name, such as a user's class
|
|
62
|
+
named after a shipped one, compete for one key. Defining the second as a
|
|
63
|
+
:class:`~pcapkit.protocols.protocol.Protocol` subclass keeps the first, and
|
|
64
|
+
registering it here replaces whichever was there, and the
|
|
65
|
+
replacement is observable through every reader of the registry, e.g.
|
|
66
|
+
:meth:`Protocol.expand_comp
|
|
67
|
+
<pcapkit.protocols.protocol.Protocol.expand_comp>`, which resolves a
|
|
68
|
+
bare protocol name through it. Per :issue:`675` the overwrite is reported,
|
|
69
|
+
matching :meth:`Protocol.register
|
|
70
|
+
<pcapkit.protocols.protocol.Protocol.register>` and the other
|
|
71
|
+
overwrite-warning registries.
|
|
72
|
+
|
|
73
|
+
The guard reads "key present **and** incumbent is a different class" --
|
|
74
|
+
presence alone is not enough. This registry's key is *derived* from the
|
|
75
|
+
class rather than supplied by a caller, and this function is the funnel
|
|
76
|
+
every wrapper registrar calls --
|
|
77
|
+
:func:`~pcapkit.foundation.registry.protocols.transport.register_tcp`,
|
|
78
|
+
:func:`~pcapkit.foundation.registry.protocols.transport.register_udp`,
|
|
79
|
+
:func:`~pcapkit.foundation.registry.protocols.transport.register_apptype`,
|
|
80
|
+
:func:`~pcapkit.foundation.registry.protocols.misc.register_linktype` and
|
|
81
|
+
the rest all end by calling it with their class, and registering their
|
|
82
|
+
code back undoes that call's write (:issue:`1505`). So registering one class under two codes, a
|
|
83
|
+
supported and documented thing to do, reaches this function twice with the
|
|
84
|
+
same class and nothing at stake; a presence-only guard would warn about an
|
|
85
|
+
overwrite that overwrote nothing. Warning on the harmless case is not free:
|
|
86
|
+
it teaches a caller to filter
|
|
87
|
+
:exc:`~pcapkit.utilities.warnings.RegistryWarning` wholesale, and that
|
|
88
|
+
filter would then hide the name collision this warning exists to
|
|
89
|
+
surface. The sibling ``register`` methods across the package, each keyed on a
|
|
90
|
+
caller-supplied ``code``, apply the same identity criterion (:issue:`718`).
|
|
91
|
+
A built-in's :class:`~pcapkit.corekit.module.ModuleDescriptor` entry is
|
|
92
|
+
the class it names for that criterion.
|
|
93
|
+
|
|
94
|
+
Making the key itself unique would resolve the collision rather than
|
|
95
|
+
merely reporting it, but it is a registry-format change that the bare-name
|
|
96
|
+
readers outside this module cannot absorb on their own -- the registry is a
|
|
97
|
+
documented public attribute, and its readers look a bare name up and then
|
|
98
|
+
degrade *silently* on a miss rather than raising, so a re-keying would not
|
|
99
|
+
announce itself either. :meth:`Protocol.expand_comp
|
|
100
|
+
<pcapkit.protocols.protocol.Protocol.expand_comp>` falls back to the
|
|
101
|
+
name as a plain string, and the ``protocol`` properties on
|
|
102
|
+
:class:`~pcapkit.foundation.reassembly.reassembly.ReassemblyMeta` and
|
|
103
|
+
:class:`~pcapkit.foundation.traceflow.traceflow.TraceFlowMeta` fall back to
|
|
104
|
+
:class:`~pcapkit.protocols.misc.raw.protocol.Raw`. The registry redesign of
|
|
105
|
+
:issue:`514` keeps this key, and its thread records the shared namespace as
|
|
106
|
+
a risk that design does not resolve, so the collision is reported here
|
|
107
|
+
rather than fixed.
|
|
108
|
+
|
|
109
|
+
Args:
|
|
110
|
+
protocol: Protocol class.
|
|
111
|
+
|
|
112
|
+
Raises:
|
|
113
|
+
pcapkit.utilities.exceptions.RegistryError: If ``protocol`` is not a
|
|
114
|
+
:class:`~pcapkit.protocols.protocol.ProtocolBase` subclass.
|
|
115
|
+
|
|
116
|
+
Warns:
|
|
117
|
+
pcapkit.utilities.warnings.RegistryWarning: If the registry already
|
|
118
|
+
holds a *different* class under this protocol's name, i.e. the
|
|
119
|
+
registration displaced another protocol class. Re-registering the
|
|
120
|
+
same class under the same name is silent.
|
|
121
|
+
|
|
122
|
+
.. versionchanged:: 1.6.0
|
|
123
|
+
|
|
124
|
+
The HTTP member classes are named
|
|
125
|
+
:class:`~pcapkit.protocols.application.httpv1.protocol.HTTPv1` and
|
|
126
|
+
:class:`~pcapkit.protocols.application.httpv2.protocol.HTTPv2`, so registering
|
|
127
|
+
one keeps its own key and no longer displaces
|
|
128
|
+
:class:`~pcapkit.protocols.application.http.protocol.HTTP` under ``'HTTP'``
|
|
129
|
+
(:issue:`2529`). The registry is
|
|
130
|
+
:attr:`ProtocolBase.__registry__ <pcapkit.protocols.protocol.ProtocolBase.__registry__>`,
|
|
131
|
+
written by :meth:`ProtocolBase.register_protocol
|
|
132
|
+
<pcapkit.protocols.protocol.ProtocolBase.register_protocol>`, where it was
|
|
133
|
+
``pcapkit.protocols.__proto__`` (:issue:`2763`).
|
|
134
|
+
|
|
135
|
+
"""
|
|
136
|
+
if not isinstance(protocol, type):
|
|
137
|
+
raise RegistryError(f'protocol must be a class, not {protocol!r}')
|
|
138
|
+
if not issubclass(protocol, ProtocolBase):
|
|
139
|
+
raise RegistryError(f'protocol must be a Protocol subclass, not {protocol!r}')
|
|
140
|
+
|
|
141
|
+
ProtocolBase.register_protocol(protocol)
|
|
142
|
+
logger.debug('registered protocol: %s', protocol.__name__)
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def _denotes(entry: 'Any', protocol: 'Any') -> 'bool':
|
|
146
|
+
"""Whether a by-name registry ``entry`` is ``protocol``, or a descriptor naming it.
|
|
147
|
+
|
|
148
|
+
A :class:`~pcapkit.corekit.module.ModuleDescriptor` names the class its
|
|
149
|
+
module binds under its name, read off :data:`sys.modules` rather than
|
|
150
|
+
imported: a class that is defined has its module loaded already.
|
|
151
|
+
|
|
152
|
+
Args:
|
|
153
|
+
entry: Registry entry, a displaced one included.
|
|
154
|
+
protocol: Protocol class.
|
|
155
|
+
|
|
156
|
+
"""
|
|
157
|
+
if entry is protocol:
|
|
158
|
+
return True
|
|
159
|
+
if isinstance(entry, ModuleDescriptor):
|
|
160
|
+
module = sys.modules.get(entry.module)
|
|
161
|
+
return module is not None and getattr(module, cast('str', entry.name), None) is protocol
|
|
162
|
+
return False
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
class _NameLease:
|
|
166
|
+
"""A by-name registry entry a code registration put there.
|
|
167
|
+
|
|
168
|
+
Each code registrar below ends by naming its class in the by-name registry,
|
|
169
|
+
and :mod:`pcapkit.foundation.registry` has no ``unregister``: a code is
|
|
170
|
+
undone by registering the entry it displaced (:issue:`1363`). Without a
|
|
171
|
+
record of that by-name write, handing a code back would restore the code and
|
|
172
|
+
leave the name behind (:issue:`1505`). A lease records what the write
|
|
173
|
+
displaced and which codes still dispatch to the class, so the last of them
|
|
174
|
+
to be handed back puts the displaced entry back, or removes the name if it
|
|
175
|
+
was new.
|
|
176
|
+
|
|
177
|
+
A lease is one write, not one class: the same class can hold two leases on
|
|
178
|
+
a name -- e.g. a built-in registered at one port over a custom class
|
|
179
|
+
shadowing it at another -- and each undoes only its own write.
|
|
180
|
+
|
|
181
|
+
"""
|
|
182
|
+
|
|
183
|
+
__slots__ = ('name', 'protocol', 'displaced', 'codes')
|
|
184
|
+
|
|
185
|
+
def __init__(self, name: 'str', protocol: 'Type[ProtocolBase]', displaced: 'Any') -> 'None':
|
|
186
|
+
#: The key written in the by-name registry.
|
|
187
|
+
self.name = name
|
|
188
|
+
#: The class written under it.
|
|
189
|
+
self.protocol = protocol
|
|
190
|
+
#: The entry it displaced, or :data:`~pcapkit.corekit.sentinels.MISSING` for a new name.
|
|
191
|
+
self.displaced = displaced
|
|
192
|
+
#: ``(destination, code)`` registrations still holding the lease.
|
|
193
|
+
self.codes = set() # type: set[tuple[type, Any]]
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
#: Name -> its leases, oldest first. Each lease displaced the one below it,
|
|
197
|
+
#: unless the name was written by other means in between; the last is the one
|
|
198
|
+
#: a lookup sees, unless the name has been written since.
|
|
199
|
+
_NAME_LEASES = {} # type: dict[str, list[_NameLease]]
|
|
200
|
+
#: ``(destination, code)`` -> the lease its registration holds.
|
|
201
|
+
_CODE_LEASES = {} # type: dict[tuple[type, Any], _NameLease]
|
|
202
|
+
#: Serialises the lease tables above, so concurrent registrars cannot tear them.
|
|
203
|
+
_LEASE_LOCK = threading.RLock()
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
def _fold_lease(stack: 'list[_NameLease]', index: 'int') -> 'None':
|
|
207
|
+
"""Retire ``stack[index]``, a lease now displacing its own class.
|
|
208
|
+
|
|
209
|
+
That happens once the lease between it and an earlier write of the same
|
|
210
|
+
class is handed back, e.g. a custom ``IPv4`` released from under the
|
|
211
|
+
built-in ``IPv4`` registered over it. Undoing it would change nothing, so
|
|
212
|
+
its codes move to the lease below when that is the same class, and
|
|
213
|
+
otherwise -- the class was named by other means -- hold nothing.
|
|
214
|
+
|
|
215
|
+
Args:
|
|
216
|
+
stack: The name's leases, oldest first.
|
|
217
|
+
index: Position of the lease to retire.
|
|
218
|
+
|
|
219
|
+
"""
|
|
220
|
+
lease = stack.pop(index)
|
|
221
|
+
below = stack[index - 1] if index > 0 else None
|
|
222
|
+
if below is not None and below.protocol is not lease.protocol:
|
|
223
|
+
below = None
|
|
224
|
+
for target in lease.codes:
|
|
225
|
+
if _CODE_LEASES.get(target) is not lease:
|
|
226
|
+
continue
|
|
227
|
+
if below is None:
|
|
228
|
+
del _CODE_LEASES[target]
|
|
229
|
+
else:
|
|
230
|
+
below.codes.add(target)
|
|
231
|
+
_CODE_LEASES[target] = below
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
def _release_name(target: 'tuple[type, Any]') -> 'None':
|
|
235
|
+
"""Hand back the lease ``target``'s registration held.
|
|
236
|
+
|
|
237
|
+
Once no code holds the lease, it leaves its name's stack. A lease on top
|
|
238
|
+
undoes its write, unless the name was written by other means since. A new
|
|
239
|
+
name is removed. A displaced class is registered back with
|
|
240
|
+
:func:`register_protocol`, the path a code's restore takes, so it warns as
|
|
241
|
+
the code's restore does (:issue:`2773`). A buried lease hands what it
|
|
242
|
+
displaced to the lease above, if that lease displaced it.
|
|
243
|
+
|
|
244
|
+
Args:
|
|
245
|
+
target: The ``(destination, code)`` being registered over.
|
|
246
|
+
|
|
247
|
+
"""
|
|
248
|
+
protocol_registry = ProtocolBase.__registry__
|
|
249
|
+
lease = _CODE_LEASES.pop(target, None)
|
|
250
|
+
if lease is None:
|
|
251
|
+
return
|
|
252
|
+
lease.codes.discard(target)
|
|
253
|
+
if lease.codes:
|
|
254
|
+
return
|
|
255
|
+
|
|
256
|
+
stack = _NAME_LEASES.get(lease.name, [])
|
|
257
|
+
index = next((i for i, item in enumerate(stack) if item is lease), None)
|
|
258
|
+
if index is None:
|
|
259
|
+
return
|
|
260
|
+
del stack[index]
|
|
261
|
+
if index < len(stack):
|
|
262
|
+
above = stack[index]
|
|
263
|
+
if _denotes(above.displaced, lease.protocol):
|
|
264
|
+
above.displaced = lease.displaced
|
|
265
|
+
if _denotes(above.displaced, above.protocol):
|
|
266
|
+
_fold_lease(stack, index)
|
|
267
|
+
elif _denotes(protocol_registry.get(lease.name), lease.protocol):
|
|
268
|
+
if lease.displaced is MISSING:
|
|
269
|
+
protocol_registry.pop(lease.name, None)
|
|
270
|
+
elif isinstance(lease.displaced, ModuleDescriptor):
|
|
271
|
+
register_protocol(lease.displaced.klass)
|
|
272
|
+
else:
|
|
273
|
+
register_protocol(lease.displaced)
|
|
274
|
+
logger.debug('released protocol: %s', lease.protocol.__name__)
|
|
275
|
+
if not stack:
|
|
276
|
+
_NAME_LEASES.pop(lease.name, None)
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
def _register_name(protocol: 'Type[ProtocolBase]', *targets: 'tuple[type, Any]') -> 'None':
|
|
280
|
+
"""Name ``protocol`` in the by-name registry for ``targets``.
|
|
281
|
+
|
|
282
|
+
The tail of every code registrar: :func:`register_protocol`, preceded by
|
|
283
|
+
releasing whatever each target code held before, and followed by a lease
|
|
284
|
+
when the write changed the name, so that registering the code back undoes
|
|
285
|
+
it (:issue:`1505`). A name already showing ``protocol`` -- shipped, named
|
|
286
|
+
when its concrete :class:`~pcapkit.protocols.protocol.Protocol` subclass was
|
|
287
|
+
defined, or registered directly -- is not
|
|
288
|
+
leased, so no restore takes it away; one showing it through a lease
|
|
289
|
+
extends that lease to ``targets``.
|
|
290
|
+
|
|
291
|
+
Args:
|
|
292
|
+
protocol: Protocol class just registered -- and so validated -- at ``targets``.
|
|
293
|
+
*targets: The ``(destination, code)`` pairs it was registered at.
|
|
294
|
+
|
|
295
|
+
"""
|
|
296
|
+
protocol_registry = ProtocolBase.__registry__
|
|
297
|
+
name = protocol.__name__.upper()
|
|
298
|
+
with _LEASE_LOCK:
|
|
299
|
+
stack = _NAME_LEASES.get(name)
|
|
300
|
+
if stack and stack[-1].protocol is protocol and _denotes(protocol_registry.get(name), protocol):
|
|
301
|
+
current = stack[-1] # type: Optional[_NameLease]
|
|
302
|
+
else:
|
|
303
|
+
current = None
|
|
304
|
+
for target in targets:
|
|
305
|
+
if current is None or _CODE_LEASES.get(target) is not current:
|
|
306
|
+
_release_name(target)
|
|
307
|
+
|
|
308
|
+
incumbent = protocol_registry.get(name, MISSING)
|
|
309
|
+
register_protocol(protocol)
|
|
310
|
+
if not _denotes(protocol_registry.get(name), protocol):
|
|
311
|
+
return
|
|
312
|
+
|
|
313
|
+
stack = _NAME_LEASES.get(name)
|
|
314
|
+
if not _denotes(incumbent, protocol):
|
|
315
|
+
lease = _NameLease(name, protocol, incumbent)
|
|
316
|
+
_NAME_LEASES.setdefault(name, []).append(lease)
|
|
317
|
+
elif stack and stack[-1].protocol is protocol:
|
|
318
|
+
lease = stack[-1]
|
|
319
|
+
else:
|
|
320
|
+
return
|
|
321
|
+
lease.codes.update(targets)
|
|
322
|
+
for target in targets:
|
|
323
|
+
_CODE_LEASES[target] = lease
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
def _iter_code_targets(code: 'Any') -> 'Iterator[tuple[Type[ProtocolBase], Any]]':
|
|
327
|
+
"""Flatten a ``code=`` argument into ``(destination, key)`` pairs.
|
|
328
|
+
|
|
329
|
+
Args:
|
|
330
|
+
code: See :func:`register_protocol_code`.
|
|
331
|
+
|
|
332
|
+
Yields:
|
|
333
|
+
One ``(destination, key)`` pair per registration the caller asked
|
|
334
|
+
for -- possibly several, e.g. a single :class:`~pcapkit.const.reg.\
|
|
335
|
+
linktype.LinkType` member yields both :class:`Frame` and :class:`PCAPNG`.
|
|
336
|
+
|
|
337
|
+
Raises:
|
|
338
|
+
RegistryError: If a value has no destination it can name or infer;
|
|
339
|
+
see :func:`register_protocol_code`.
|
|
340
|
+
|
|
341
|
+
"""
|
|
342
|
+
if isinstance(code, dict):
|
|
343
|
+
yield from code.items()
|
|
344
|
+
return
|
|
345
|
+
|
|
346
|
+
if isinstance(code, (enum.Enum, aenum.Enum)):
|
|
347
|
+
# NOTE: ``getattr`` may inherit: aenum refuses to extend an enumeration with members, so
|
|
348
|
+
# no registry has a subclass, and the memberless ``AppType`` declares no ``__proto_dest__``.
|
|
349
|
+
destinations = getattr(type(code), '__proto_dest__', None)
|
|
350
|
+
if not destinations:
|
|
351
|
+
raise RegistryError(
|
|
352
|
+
f'no destination registry is known for enum type {type(code).__name__!r} '
|
|
353
|
+
f'(key {code!r}); pass an explicit destination, e.g. code={{SomeClass: {code!r}}}')
|
|
354
|
+
for descriptor in destinations:
|
|
355
|
+
yield descriptor.klass, code
|
|
356
|
+
return
|
|
357
|
+
|
|
358
|
+
if isinstance(code, (str, bytes)):
|
|
359
|
+
raise RegistryError(f'code must be an enum member, a {{destination: key}} mapping, or an '
|
|
360
|
+
f'iterable thereof, not {code!r}')
|
|
361
|
+
|
|
362
|
+
if isinstance(code, collections.abc.Iterable):
|
|
363
|
+
for item in code:
|
|
364
|
+
yield from _iter_code_targets(item)
|
|
365
|
+
return
|
|
366
|
+
|
|
367
|
+
raise RegistryError(f'raw key {code!r} has no destination registry it can infer; pass an '
|
|
368
|
+
f'explicit destination, e.g. code={{TCP: {code!r}}}')
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
def register_protocol_code(protocol: 'Type[ProtocolBase]', code: 'Any') -> 'None':
|
|
372
|
+
r"""Register ``protocol`` into the next-layer dispatch registry (or
|
|
373
|
+
registries) named by ``code``.
|
|
374
|
+
|
|
375
|
+
This is what backs the ``code`` class keyword of
|
|
376
|
+
:class:`~pcapkit.protocols.protocol.ProtocolBase` subclasses; it can also
|
|
377
|
+
be called directly to register a class that declined at class-definition
|
|
378
|
+
time.
|
|
379
|
+
|
|
380
|
+
``code`` is normalised into a flat sequence of targets, where each item
|
|
381
|
+
is either:
|
|
382
|
+
|
|
383
|
+
* an enum member, whose *type* names the class(es) owning the matching
|
|
384
|
+
``__proto__`` in its
|
|
385
|
+
:attr:`__proto_dest__ <pcapkit.const.reg.ethertype.EtherType.__proto_dest__>` --
|
|
386
|
+
:class:`~pcapkit.const.reg.ethertype.EtherType` to
|
|
387
|
+
:class:`~pcapkit.protocols.link.link.Link`,
|
|
388
|
+
:class:`~pcapkit.const.reg.transtype.TransType` to
|
|
389
|
+
:class:`~pcapkit.protocols.internet.internet.Internet`,
|
|
390
|
+
:class:`~pcapkit.const.sctp.payload_protocol_identifier.PayloadProtocolIdentifier`
|
|
391
|
+
to :class:`~pcapkit.protocols.transport.sctp.protocol.SCTP`,
|
|
392
|
+
:class:`~pcapkit.const.linux.arphrd.ARPHRD` to
|
|
393
|
+
:class:`~pcapkit.protocols.link.linux_sll.protocol.LinuxSLL`, and
|
|
394
|
+
:class:`~pcapkit.const.reg.linktype.LinkType` to *both*
|
|
395
|
+
:class:`~pcapkit.protocols.misc.pcap.frame.protocol.Frame` **and**
|
|
396
|
+
:class:`~pcapkit.protocols.misc.pcapng.protocol.PCAPNG`; or
|
|
397
|
+
* a :class:`dict` mapping an explicit destination class to a key -- the
|
|
398
|
+
only form accepted for a bare :class:`int`, since e.g. a port number
|
|
399
|
+
does not say by itself whether it means
|
|
400
|
+
:class:`~pcapkit.protocols.transport.tcp.protocol.TCP` or
|
|
401
|
+
:class:`~pcapkit.protocols.transport.udp.protocol.UDP`;
|
|
402
|
+
|
|
403
|
+
or an iterable of either, to register ``protocol`` into several
|
|
404
|
+
registries from one call -- e.g. a
|
|
405
|
+
:class:`~pcapkit.protocols.link.l2tp.protocol.L2TP` subclass reachable both by its
|
|
406
|
+
IP protocol number and by a UDP port:
|
|
407
|
+
|
|
408
|
+
.. code-block:: python
|
|
409
|
+
|
|
410
|
+
register_protocol_code(L2TPv3, [TransType.L2TP, {UDP: 1701}])
|
|
411
|
+
|
|
412
|
+
The explicit mapping form is accepted for any key, even one whose type
|
|
413
|
+
could be inferred -- being more explicit than required is never an
|
|
414
|
+
error.
|
|
415
|
+
|
|
416
|
+
Note:
|
|
417
|
+
That example names ``L2TPv3``, which this package does not implement,
|
|
418
|
+
rather than :class:`~pcapkit.protocols.link.l2tpv2.protocol.L2TPv2`. It is
|
|
419
|
+
v3 that is genuinely reachable both ways: :rfc:`3931` §4.1.1 puts it
|
|
420
|
+
directly over IP on protocol 115 and §4.1.2 puts it over UDP on port
|
|
421
|
+
1701. :class:`L2TPv2 <pcapkit.protocols.link.l2tpv2.protocol.L2TPv2>` answers on
|
|
422
|
+
port 1701 only, and registering *it* at
|
|
423
|
+
:attr:`TransType.L2TP <pcapkit.const.reg.transtype.TransType.L2TP>` would point the
|
|
424
|
+
:rfc:`2661` parser at a v3-over-IP header -- see :class:`~pcapkit.protocols.link.l2tp.protocol.L2TP`
|
|
425
|
+
and GitHub issue :issue:`548` for what that produced when measured.
|
|
426
|
+
|
|
427
|
+
Args:
|
|
428
|
+
protocol: Protocol class to register.
|
|
429
|
+
code: Registration key(s); see above.
|
|
430
|
+
|
|
431
|
+
Raises:
|
|
432
|
+
RegistryError: If a bare :class:`int` (or any other non-enum,
|
|
433
|
+
non-mapping value) is given without an explicit destination, or if
|
|
434
|
+
an enum member's type declares no
|
|
435
|
+
:attr:`__proto_dest__ <pcapkit.const.reg.ethertype.EtherType.__proto_dest__>` --
|
|
436
|
+
inference refuses rather than guesses; or if a key is not of the
|
|
437
|
+
type its destination's registry is keyed by, as its typed registrar
|
|
438
|
+
would reject it, e.g. ``{Frame: TransType.ICMP}``. What a registry is
|
|
439
|
+
keyed by is read from the
|
|
440
|
+
:attr:`__proto_key__ <pcapkit.protocols.link.link.Link.__proto_key__>`
|
|
441
|
+
declared by the class owning it, so a destination sharing another's
|
|
442
|
+
registry is checked as its owner is, and one whose owner declares no
|
|
443
|
+
pairing is not checked. Every target is checked before any is
|
|
444
|
+
registered, so a rejected ``code`` leaves every registry as it was
|
|
445
|
+
(:issue:`2268`).
|
|
446
|
+
|
|
447
|
+
"""
|
|
448
|
+
targets = list(_iter_code_targets(code))
|
|
449
|
+
for destination, key in targets:
|
|
450
|
+
owner = next((klass for klass in getattr(destination, '__mro__', ())
|
|
451
|
+
if '__proto__' in vars(klass)), None)
|
|
452
|
+
if owner is None:
|
|
453
|
+
continue
|
|
454
|
+
|
|
455
|
+
# NOTE: read from the owner's own ``vars()``, not ``getattr``, so a class keeping its own
|
|
456
|
+
# registry, as ``Loopback`` does by address family, is not checked against its parent's.
|
|
457
|
+
pairing = vars(owner).get('__proto_key__')
|
|
458
|
+
if pairing is not None:
|
|
459
|
+
kind, number = pairing
|
|
460
|
+
_check_code(key, kind, owner, number=number)
|
|
461
|
+
|
|
462
|
+
for destination, key in targets:
|
|
463
|
+
destination.register(key, protocol)
|
|
464
|
+
logger.debug('registered %s into %s.__proto__: %s', protocol.__name__,
|
|
465
|
+
destination.__name__, key)
|
|
466
|
+
|
|
467
|
+
|
|
468
|
+
def _check_code(code: 'Any', kind: 'Optional[type]', target: 'Type[ProtocolBase]', *,
|
|
469
|
+
number: 'bool' = False) -> 'None':
|
|
470
|
+
"""Reject a registration key that is not a member of the enum its
|
|
471
|
+
destination registry is keyed by.
|
|
472
|
+
|
|
473
|
+
Each registrar typed on one enum calls this before touching any registry,
|
|
474
|
+
as does :func:`register_protocol_code` for an inferred or explicitly
|
|
475
|
+
named destination, so a bad ``code`` leaves every registry as it was
|
|
476
|
+
(:issue:`2186`). The check is on the type, not the value: the registry
|
|
477
|
+
enums compare equal to their values, so a member of another enum would
|
|
478
|
+
key the entry of the member it equals, e.g.
|
|
479
|
+
:attr:`TransType.ICMP <pcapkit.const.reg.transtype.TransType.ICMP>` would
|
|
480
|
+
replace :attr:`LinkType.ETHERNET <pcapkit.const.reg.linktype.LinkType.ETHERNET>`
|
|
481
|
+
(:issue:`2224`).
|
|
482
|
+
|
|
483
|
+
Args:
|
|
484
|
+
code: Registration key handed to the registrar.
|
|
485
|
+
kind: Enum the registrar is typed on, or :data:`None` for a registry
|
|
486
|
+
keyed by a number no enum names, which takes a bare :class:`int`
|
|
487
|
+
only (:issue:`2511`).
|
|
488
|
+
target: Protocol class whose registry ``code`` is destined for, named in
|
|
489
|
+
the error message so a rejection says *whose* registry rejected the
|
|
490
|
+
key rather than only what it wanted -- its callers share one
|
|
491
|
+
message, and several of them are typed on the same enum.
|
|
492
|
+
number: Whether a bare :class:`int` is a valid key too, as for the
|
|
493
|
+
registrars keyed on a port number or a payload protocol identifier.
|
|
494
|
+
Implied when ``kind`` is :data:`None`.
|
|
495
|
+
|
|
496
|
+
Raises:
|
|
497
|
+
RegistryError: If ``code`` is not a member of ``kind`` and, with
|
|
498
|
+
``number``, not an :class:`int` either. A member of another enum is
|
|
499
|
+
rejected even where an :class:`int` is accepted, and so is a
|
|
500
|
+
:class:`bool`, which would otherwise key ``0`` or ``1``
|
|
501
|
+
(:issue:`2269`).
|
|
502
|
+
|
|
503
|
+
"""
|
|
504
|
+
if kind is not None and isinstance(code, kind):
|
|
505
|
+
return
|
|
506
|
+
number = number or kind is None
|
|
507
|
+
member = isinstance(code, (enum.Enum, aenum.Enum))
|
|
508
|
+
if number and isinstance(code, int) and not isinstance(code, bool) and not member:
|
|
509
|
+
return
|
|
510
|
+
if kind is None:
|
|
511
|
+
expected = 'an int'
|
|
512
|
+
elif number:
|
|
513
|
+
expected = f'an int or a member of {kind.__name__}'
|
|
514
|
+
else:
|
|
515
|
+
expected = f'a member of {kind.__name__}'
|
|
516
|
+
if member:
|
|
517
|
+
raise RegistryError(f'{target.__name__}: code must be {expected}, not a member of '
|
|
518
|
+
f'{type(code).__name__}: {code!r}')
|
|
519
|
+
raise RegistryError(f'{target.__name__}: code must be {expected}, not {code!r}')
|