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.
Files changed (770) hide show
  1. pcapkit/__init__.py +107 -0
  2. pcapkit/__main__.py +158 -0
  3. pcapkit/all.py +168 -0
  4. pcapkit/const/__init__.py +143 -0
  5. pcapkit/const/arp/__init__.py +35 -0
  6. pcapkit/const/arp/hardware.py +195 -0
  7. pcapkit/const/arp/operation.py +145 -0
  8. pcapkit/const/dccp/__init__.py +58 -0
  9. pcapkit/const/dccp/ack_vector_state.py +73 -0
  10. pcapkit/const/dccp/drop_code.py +79 -0
  11. pcapkit/const/dccp/feature.py +106 -0
  12. pcapkit/const/dccp/option.py +133 -0
  13. pcapkit/const/dccp/packet_type.py +103 -0
  14. pcapkit/const/dccp/reset_code.py +115 -0
  15. pcapkit/const/esp/__init__.py +49 -0
  16. pcapkit/const/esp/cipher.py +265 -0
  17. pcapkit/const/esp/integrity.py +154 -0
  18. pcapkit/const/ftp/__init__.py +35 -0
  19. pcapkit/const/ftp/command.py +659 -0
  20. pcapkit/const/ftp/return_code.py +409 -0
  21. pcapkit/const/hip/__init__.py +121 -0
  22. pcapkit/const/hip/certificate.py +91 -0
  23. pcapkit/const/hip/cipher.py +79 -0
  24. pcapkit/const/hip/di.py +73 -0
  25. pcapkit/const/hip/ecdsa_curve.py +73 -0
  26. pcapkit/const/hip/ecdsa_low_curve.py +70 -0
  27. pcapkit/const/hip/eddsa_curve.py +79 -0
  28. pcapkit/const/hip/esp_transform_suite.py +112 -0
  29. pcapkit/const/hip/group.py +100 -0
  30. pcapkit/const/hip/hi_algorithm.py +100 -0
  31. pcapkit/const/hip/hit_suite.py +82 -0
  32. pcapkit/const/hip/nat_traversal.py +76 -0
  33. pcapkit/const/hip/notify_message.py +214 -0
  34. pcapkit/const/hip/packet.py +103 -0
  35. pcapkit/const/hip/parameter.py +391 -0
  36. pcapkit/const/hip/registration.py +82 -0
  37. pcapkit/const/hip/registration_failure.py +98 -0
  38. pcapkit/const/hip/suite.py +85 -0
  39. pcapkit/const/hip/transport.py +73 -0
  40. pcapkit/const/http/__init__.py +52 -0
  41. pcapkit/const/http/error_code.py +108 -0
  42. pcapkit/const/http/frame.py +109 -0
  43. pcapkit/const/http/method.py +329 -0
  44. pcapkit/const/http/setting.py +110 -0
  45. pcapkit/const/http/status_code.py +347 -0
  46. pcapkit/const/icmp/__init__.py +52 -0
  47. pcapkit/const/icmp/destination_unreachable_code.py +111 -0
  48. pcapkit/const/icmp/parameter_problem_code.py +70 -0
  49. pcapkit/const/icmp/time_exceeded_code.py +67 -0
  50. pcapkit/const/icmp/type.py +179 -0
  51. pcapkit/const/icmpv6/__init__.py +52 -0
  52. pcapkit/const/icmpv6/destination_unreachable_code.py +91 -0
  53. pcapkit/const/icmpv6/parameter_problem_code.py +94 -0
  54. pcapkit/const/icmpv6/time_exceeded_code.py +67 -0
  55. pcapkit/const/icmpv6/type.py +209 -0
  56. pcapkit/const/ieee802_11/__init__.py +52 -0
  57. pcapkit/const/ieee802_11/control_subtype.py +106 -0
  58. pcapkit/const/ieee802_11/data_subtype.py +97 -0
  59. pcapkit/const/ieee802_11/extension_subtype.py +70 -0
  60. pcapkit/const/ieee802_11/management_subtype.py +109 -0
  61. pcapkit/const/ieee802_11/type.py +73 -0
  62. pcapkit/const/igmp/__init__.py +37 -0
  63. pcapkit/const/igmp/record_type.py +73 -0
  64. pcapkit/const/igmp/type.py +112 -0
  65. pcapkit/const/ipv4/__init__.py +79 -0
  66. pcapkit/const/ipv4/classification_level.py +77 -0
  67. pcapkit/const/ipv4/option_class.py +69 -0
  68. pcapkit/const/ipv4/option_number.py +151 -0
  69. pcapkit/const/ipv4/protection_authority.py +77 -0
  70. pcapkit/const/ipv4/qs_function.py +65 -0
  71. pcapkit/const/ipv4/router_alert.py +268 -0
  72. pcapkit/const/ipv4/tos_del.py +65 -0
  73. pcapkit/const/ipv4/tos_ecn.py +69 -0
  74. pcapkit/const/ipv4/tos_pre.py +77 -0
  75. pcapkit/const/ipv4/tos_rel.py +65 -0
  76. pcapkit/const/ipv4/tos_thr.py +65 -0
  77. pcapkit/const/ipv4/ts_flag.py +67 -0
  78. pcapkit/const/ipv6/__init__.py +70 -0
  79. pcapkit/const/ipv6/extension_header.py +86 -0
  80. pcapkit/const/ipv6/option.py +151 -0
  81. pcapkit/const/ipv6/option_action.py +69 -0
  82. pcapkit/const/ipv6/qs_function.py +65 -0
  83. pcapkit/const/ipv6/router_alert.py +280 -0
  84. pcapkit/const/ipv6/routing.py +94 -0
  85. pcapkit/const/ipv6/seed_id.py +69 -0
  86. pcapkit/const/ipv6/smf_dpd_mode.py +65 -0
  87. pcapkit/const/ipv6/tagger_id.py +76 -0
  88. pcapkit/const/ipx/__init__.py +37 -0
  89. pcapkit/const/ipx/packet.py +86 -0
  90. pcapkit/const/ipx/socket.py +121 -0
  91. pcapkit/const/l2tp/__init__.py +30 -0
  92. pcapkit/const/l2tp/type.py +65 -0
  93. pcapkit/const/linux/__init__.py +28 -0
  94. pcapkit/const/linux/arphrd.py +91 -0
  95. pcapkit/const/mh/__init__.py +259 -0
  96. pcapkit/const/mh/access_type.py +106 -0
  97. pcapkit/const/mh/ack_status_code.py +85 -0
  98. pcapkit/const/mh/ani_suboption.py +88 -0
  99. pcapkit/const/mh/auth_subtype.py +67 -0
  100. pcapkit/const/mh/binding_ack_flag.py +82 -0
  101. pcapkit/const/mh/binding_error.py +65 -0
  102. pcapkit/const/mh/binding_revocation.py +73 -0
  103. pcapkit/const/mh/binding_update_flag.py +97 -0
  104. pcapkit/const/mh/cga_extension.py +80 -0
  105. pcapkit/const/mh/cga_sec.py +71 -0
  106. pcapkit/const/mh/cga_type.py +82 -0
  107. pcapkit/const/mh/dhcp_support_mode.py +67 -0
  108. pcapkit/const/mh/dns_status_code.py +79 -0
  109. pcapkit/const/mh/dsmip6_tls_packet.py +76 -0
  110. pcapkit/const/mh/dsmipv6_home_address.py +88 -0
  111. pcapkit/const/mh/enumerating_algorithm.py +70 -0
  112. pcapkit/const/mh/fb_ack_status.py +76 -0
  113. pcapkit/const/mh/fb_action.py +85 -0
  114. pcapkit/const/mh/fb_indication_trigger.py +79 -0
  115. pcapkit/const/mh/fb_type.py +73 -0
  116. pcapkit/const/mh/flow_id_status.py +91 -0
  117. pcapkit/const/mh/flow_id_suboption.py +85 -0
  118. pcapkit/const/mh/handoff_type.py +85 -0
  119. pcapkit/const/mh/handover_ack_flag.py +70 -0
  120. pcapkit/const/mh/handover_ack_status.py +106 -0
  121. pcapkit/const/mh/handover_initiate_flag.py +73 -0
  122. pcapkit/const/mh/handover_initiate_status.py +76 -0
  123. pcapkit/const/mh/home_address_reply.py +85 -0
  124. pcapkit/const/mh/lla_code.py +77 -0
  125. pcapkit/const/mh/lma_mag_suboption.py +73 -0
  126. pcapkit/const/mh/mn_group_id.py +73 -0
  127. pcapkit/const/mh/mn_id_subtype.py +91 -0
  128. pcapkit/const/mh/operator_id.py +77 -0
  129. pcapkit/const/mh/option.py +274 -0
  130. pcapkit/const/mh/packet.py +133 -0
  131. pcapkit/const/mh/qos_attribute.py +103 -0
  132. pcapkit/const/mh/revocation_status_code.py +97 -0
  133. pcapkit/const/mh/revocation_trigger.py +100 -0
  134. pcapkit/const/mh/status_code.py +246 -0
  135. pcapkit/const/mh/traffic_selector.py +76 -0
  136. pcapkit/const/mh/upa_status.py +85 -0
  137. pcapkit/const/mh/upn_reason.py +94 -0
  138. pcapkit/const/ngap/__init__.py +44 -0
  139. pcapkit/const/ngap/procedure_code.py +223 -0
  140. pcapkit/const/ngap/protocol_ie.py +937 -0
  141. pcapkit/const/ospf/__init__.py +37 -0
  142. pcapkit/const/ospf/authentication.py +79 -0
  143. pcapkit/const/ospf/packet.py +85 -0
  144. pcapkit/const/pcapng/__init__.py +71 -0
  145. pcapkit/const/pcapng/block_type.py +166 -0
  146. pcapkit/const/pcapng/filter_type.py +62 -0
  147. pcapkit/const/pcapng/hash_algorithm.py +73 -0
  148. pcapkit/const/pcapng/option_type.py +422 -0
  149. pcapkit/const/pcapng/record_type.py +70 -0
  150. pcapkit/const/pcapng/secrets_type.py +69 -0
  151. pcapkit/const/pcapng/tls_key_label.py +89 -0
  152. pcapkit/const/pcapng/verdict_type.py +67 -0
  153. pcapkit/const/radiotap/__init__.py +116 -0
  154. pcapkit/const/radiotap/ampdu_flags.py +85 -0
  155. pcapkit/const/radiotap/channel_flags.py +94 -0
  156. pcapkit/const/radiotap/eht_known.py +124 -0
  157. pcapkit/const/radiotap/field_type.py +165 -0
  158. pcapkit/const/radiotap/flags.py +85 -0
  159. pcapkit/const/radiotap/he_data1_known.py +103 -0
  160. pcapkit/const/radiotap/he_data2_known.py +88 -0
  161. pcapkit/const/radiotap/he_mu_flags1_known.py +85 -0
  162. pcapkit/const/radiotap/he_mu_flags2_known.py +67 -0
  163. pcapkit/const/radiotap/he_mu_other_user_known.py +85 -0
  164. pcapkit/const/radiotap/lsig_data1.py +67 -0
  165. pcapkit/const/radiotap/mcs_known.py +85 -0
  166. pcapkit/const/radiotap/rx_flags.py +64 -0
  167. pcapkit/const/radiotap/s1g_known.py +85 -0
  168. pcapkit/const/radiotap/timestamp_flags.py +67 -0
  169. pcapkit/const/radiotap/tx_flags.py +82 -0
  170. pcapkit/const/radiotap/usig_common_known.py +85 -0
  171. pcapkit/const/radiotap/vht_coding.py +73 -0
  172. pcapkit/const/radiotap/vht_flags.py +84 -0
  173. pcapkit/const/radiotap/vht_known.py +90 -0
  174. pcapkit/const/reg/__init__.py +54 -0
  175. pcapkit/const/reg/apptype/__init__.py +164 -0
  176. pcapkit/const/reg/apptype/apptype.py +5233 -0
  177. pcapkit/const/reg/apptype/dccp.py +112 -0
  178. pcapkit/const/reg/apptype/sctp.py +432 -0
  179. pcapkit/const/reg/apptype/tcp.py +25154 -0
  180. pcapkit/const/reg/apptype/udp.py +24563 -0
  181. pcapkit/const/reg/ethertype.py +740 -0
  182. pcapkit/const/reg/linktype.py +811 -0
  183. pcapkit/const/reg/transtype.py +552 -0
  184. pcapkit/const/sctp/__init__.py +49 -0
  185. pcapkit/const/sctp/cause_code.py +146 -0
  186. pcapkit/const/sctp/chunk.py +164 -0
  187. pcapkit/const/sctp/parameter.py +170 -0
  188. pcapkit/const/sctp/payload_protocol_identifier.py +325 -0
  189. pcapkit/const/sslv2/__init__.py +37 -0
  190. pcapkit/const/sslv2/handshake_type.py +88 -0
  191. pcapkit/const/sslv2/version.py +64 -0
  192. pcapkit/const/tcp/__init__.py +47 -0
  193. pcapkit/const/tcp/checksum.py +69 -0
  194. pcapkit/const/tcp/flags.py +96 -0
  195. pcapkit/const/tcp/mp_tcp_option.py +95 -0
  196. pcapkit/const/tcp/option.py +210 -0
  197. pcapkit/const/tls/__init__.py +44 -0
  198. pcapkit/const/tls/content_type.py +99 -0
  199. pcapkit/const/tls/extension_type.py +382 -0
  200. pcapkit/const/tls/handshake_type.py +154 -0
  201. pcapkit/const/vlan/__init__.py +32 -0
  202. pcapkit/const/vlan/priority_level.py +85 -0
  203. pcapkit/corekit/__init__.py +64 -0
  204. pcapkit/corekit/checksum/__init__.py +24 -0
  205. pcapkit/corekit/checksum/internet.py +253 -0
  206. pcapkit/corekit/context.py +248 -0
  207. pcapkit/corekit/decorators.py +328 -0
  208. pcapkit/corekit/enum.py +742 -0
  209. pcapkit/corekit/fields/__init__.py +46 -0
  210. pcapkit/corekit/fields/collections.py +646 -0
  211. pcapkit/corekit/fields/field.py +643 -0
  212. pcapkit/corekit/fields/ipaddress.py +582 -0
  213. pcapkit/corekit/fields/misc.py +843 -0
  214. pcapkit/corekit/fields/numbers.py +1279 -0
  215. pcapkit/corekit/fields/strings.py +445 -0
  216. pcapkit/corekit/infoclass.py +1231 -0
  217. pcapkit/corekit/io.py +980 -0
  218. pcapkit/corekit/module.py +133 -0
  219. pcapkit/corekit/multidict.py +676 -0
  220. pcapkit/corekit/packet.py +179 -0
  221. pcapkit/corekit/protochain.py +266 -0
  222. pcapkit/corekit/schema/__init__.py +20 -0
  223. pcapkit/corekit/schema/byteorder.py +89 -0
  224. pcapkit/corekit/schema/ipaddress.py +210 -0
  225. pcapkit/corekit/schema/jumbogram.py +66 -0
  226. pcapkit/corekit/schema/padding.py +50 -0
  227. pcapkit/corekit/schema/shortread.py +150 -0
  228. pcapkit/corekit/sentinels.py +597 -0
  229. pcapkit/corekit/version.py +40 -0
  230. pcapkit/dumpkit/__init__.py +14 -0
  231. pcapkit/dumpkit/common.py +778 -0
  232. pcapkit/dumpkit/null.py +72 -0
  233. pcapkit/dumpkit/pcap.py +292 -0
  234. pcapkit/foundation/__init__.py +63 -0
  235. pcapkit/foundation/analysis/__init__.py +27 -0
  236. pcapkit/foundation/analysis/dtls.py +61 -0
  237. pcapkit/foundation/analysis/ip.py +88 -0
  238. pcapkit/foundation/analysis/tcp.py +87 -0
  239. pcapkit/foundation/engines/__init__.py +35 -0
  240. pcapkit/foundation/engines/_pcap_backend.py +358 -0
  241. pcapkit/foundation/engines/dpkt.py +680 -0
  242. pcapkit/foundation/engines/engine.py +318 -0
  243. pcapkit/foundation/engines/pcap.py +259 -0
  244. pcapkit/foundation/engines/pcap_ct.py +469 -0
  245. pcapkit/foundation/engines/pcapng.py +513 -0
  246. pcapkit/foundation/engines/pypcap.py +386 -0
  247. pcapkit/foundation/engines/pypcapfile.py +477 -0
  248. pcapkit/foundation/engines/pyshark.py +374 -0
  249. pcapkit/foundation/engines/scapy.py +451 -0
  250. pcapkit/foundation/extraction.py +1833 -0
  251. pcapkit/foundation/reassembly/__init__.py +55 -0
  252. pcapkit/foundation/reassembly/data/__init__.py +43 -0
  253. pcapkit/foundation/reassembly/data/data.py +300 -0
  254. pcapkit/foundation/reassembly/data/dtls.py +186 -0
  255. pcapkit/foundation/reassembly/data/ip.py +203 -0
  256. pcapkit/foundation/reassembly/data/tcp.py +296 -0
  257. pcapkit/foundation/reassembly/dtls.py +340 -0
  258. pcapkit/foundation/reassembly/ip.py +639 -0
  259. pcapkit/foundation/reassembly/ipv4.py +80 -0
  260. pcapkit/foundation/reassembly/ipv6.py +206 -0
  261. pcapkit/foundation/reassembly/reassembly.py +605 -0
  262. pcapkit/foundation/reassembly/tcp.py +870 -0
  263. pcapkit/foundation/registry/__init__.py +56 -0
  264. pcapkit/foundation/registry/foundation.py +362 -0
  265. pcapkit/foundation/registry/protocols/__init__.py +67 -0
  266. pcapkit/foundation/registry/protocols/application.py +119 -0
  267. pcapkit/foundation/registry/protocols/internet.py +506 -0
  268. pcapkit/foundation/registry/protocols/link.py +378 -0
  269. pcapkit/foundation/registry/protocols/misc.py +352 -0
  270. pcapkit/foundation/registry/protocols/protocol.py +519 -0
  271. pcapkit/foundation/registry/protocols/transport.py +647 -0
  272. pcapkit/foundation/traceflow/__init__.py +45 -0
  273. pcapkit/foundation/traceflow/data/__init__.py +17 -0
  274. pcapkit/foundation/traceflow/data/data.py +193 -0
  275. pcapkit/foundation/traceflow/data/tcp.py +212 -0
  276. pcapkit/foundation/traceflow/tcp.py +581 -0
  277. pcapkit/foundation/traceflow/traceflow.py +593 -0
  278. pcapkit/interface/__init__.py +23 -0
  279. pcapkit/interface/core.py +265 -0
  280. pcapkit/interface/misc.py +186 -0
  281. pcapkit/interface/registry.py +116 -0
  282. pcapkit/protocols/__init__.py +95 -0
  283. pcapkit/protocols/application/NotImplemented/bgp.py +0 -0
  284. pcapkit/protocols/application/NotImplemented/dhcp.py +0 -0
  285. pcapkit/protocols/application/NotImplemented/dhcpv6.py +0 -0
  286. pcapkit/protocols/application/NotImplemented/dns.py +0 -0
  287. pcapkit/protocols/application/NotImplemented/imap.py +0 -0
  288. pcapkit/protocols/application/NotImplemented/ldap.py +0 -0
  289. pcapkit/protocols/application/NotImplemented/mqtt.py +0 -0
  290. pcapkit/protocols/application/NotImplemented/nntp.py +0 -0
  291. pcapkit/protocols/application/NotImplemented/ntp.py +0 -0
  292. pcapkit/protocols/application/NotImplemented/onc_rpc.py +0 -0
  293. pcapkit/protocols/application/NotImplemented/pop.py +0 -0
  294. pcapkit/protocols/application/NotImplemented/rip.py +0 -0
  295. pcapkit/protocols/application/NotImplemented/rtp.py +0 -0
  296. pcapkit/protocols/application/NotImplemented/sip.py +0 -0
  297. pcapkit/protocols/application/NotImplemented/smtp.py +0 -0
  298. pcapkit/protocols/application/NotImplemented/snmp.py +0 -0
  299. pcapkit/protocols/application/NotImplemented/ssh.py +0 -0
  300. pcapkit/protocols/application/NotImplemented/telnet.py +0 -0
  301. pcapkit/protocols/application/NotImplemented/xmpp.py +0 -0
  302. pcapkit/protocols/application/__init__.py +79 -0
  303. pcapkit/protocols/application/application.py +189 -0
  304. pcapkit/protocols/application/drarp/__init__.py +14 -0
  305. pcapkit/protocols/application/drarp/protocol.py +53 -0
  306. pcapkit/protocols/application/dtls/__init__.py +30 -0
  307. pcapkit/protocols/application/dtls/data.py +150 -0
  308. pcapkit/protocols/application/dtls/protocol.py +1137 -0
  309. pcapkit/protocols/application/dtls/schema.py +157 -0
  310. pcapkit/protocols/application/ftp/__init__.py +27 -0
  311. pcapkit/protocols/application/ftp/data.py +72 -0
  312. pcapkit/protocols/application/ftp/protocol.py +410 -0
  313. pcapkit/protocols/application/ftp/schema.py +21 -0
  314. pcapkit/protocols/application/ftp_data/__init__.py +14 -0
  315. pcapkit/protocols/application/ftp_data/protocol.py +97 -0
  316. pcapkit/protocols/application/http/__init__.py +14 -0
  317. pcapkit/protocols/application/http/protocol.py +773 -0
  318. pcapkit/protocols/application/httpv1/__init__.py +28 -0
  319. pcapkit/protocols/application/httpv1/data.py +98 -0
  320. pcapkit/protocols/application/httpv1/protocol.py +610 -0
  321. pcapkit/protocols/application/httpv1/schema.py +29 -0
  322. pcapkit/protocols/application/httpv2/__init__.py +61 -0
  323. pcapkit/protocols/application/httpv2/data.py +347 -0
  324. pcapkit/protocols/application/httpv2/protocol.py +1724 -0
  325. pcapkit/protocols/application/httpv2/schema.py +430 -0
  326. pcapkit/protocols/application/ngap/__init__.py +29 -0
  327. pcapkit/protocols/application/ngap/data.py +124 -0
  328. pcapkit/protocols/application/ngap/protocol.py +578 -0
  329. pcapkit/protocols/application/ngap/schema.py +29 -0
  330. pcapkit/protocols/application/ospf/__init__.py +29 -0
  331. pcapkit/protocols/application/ospf/data.py +79 -0
  332. pcapkit/protocols/application/ospf/protocol.py +544 -0
  333. pcapkit/protocols/application/ospf/schema.py +109 -0
  334. pcapkit/protocols/application/rarp/__init__.py +14 -0
  335. pcapkit/protocols/application/rarp/protocol.py +111 -0
  336. pcapkit/protocols/application/ssl/__init__.py +43 -0
  337. pcapkit/protocols/application/ssl/data.py +322 -0
  338. pcapkit/protocols/application/ssl/protocol.py +1522 -0
  339. pcapkit/protocols/application/sslv2/__init__.py +32 -0
  340. pcapkit/protocols/application/sslv2/data.py +93 -0
  341. pcapkit/protocols/application/sslv2/protocol.py +543 -0
  342. pcapkit/protocols/application/sslv2/schema.py +304 -0
  343. pcapkit/protocols/application/sslv3/__init__.py +14 -0
  344. pcapkit/protocols/application/sslv3/protocol.py +51 -0
  345. pcapkit/protocols/application/tls/__init__.py +25 -0
  346. pcapkit/protocols/application/tls/data.py +40 -0
  347. pcapkit/protocols/application/tls/protocol.py +561 -0
  348. pcapkit/protocols/application/tls/schema.py +44 -0
  349. pcapkit/protocols/data.py +76 -0
  350. pcapkit/protocols/internet/NotImplemented/ecn.py +0 -0
  351. pcapkit/protocols/internet/NotImplemented/shim6.py +0 -0
  352. pcapkit/protocols/internet/__init__.py +87 -0
  353. pcapkit/protocols/internet/ah/__init__.py +25 -0
  354. pcapkit/protocols/internet/ah/data.py +39 -0
  355. pcapkit/protocols/internet/ah/protocol.py +343 -0
  356. pcapkit/protocols/internet/ah/schema.py +57 -0
  357. pcapkit/protocols/internet/esp/__init__.py +25 -0
  358. pcapkit/protocols/internet/esp/data.py +71 -0
  359. pcapkit/protocols/internet/esp/protocol.py +1509 -0
  360. pcapkit/protocols/internet/esp/schema.py +46 -0
  361. pcapkit/protocols/internet/hip/__init__.py +169 -0
  362. pcapkit/protocols/internet/hip/data.py +1109 -0
  363. pcapkit/protocols/internet/hip/protocol.py +5697 -0
  364. pcapkit/protocols/internet/hip/schema.py +1654 -0
  365. pcapkit/protocols/internet/hopopt/__init__.py +80 -0
  366. pcapkit/protocols/internet/hopopt/data.py +445 -0
  367. pcapkit/protocols/internet/hopopt/protocol.py +2346 -0
  368. pcapkit/protocols/internet/hopopt/schema.py +686 -0
  369. pcapkit/protocols/internet/icmp/__init__.py +14 -0
  370. pcapkit/protocols/internet/icmp/protocol.py +201 -0
  371. pcapkit/protocols/internet/icmpv4/__init__.py +38 -0
  372. pcapkit/protocols/internet/icmpv4/data.py +153 -0
  373. pcapkit/protocols/internet/icmpv4/protocol.py +652 -0
  374. pcapkit/protocols/internet/icmpv4/schema.py +135 -0
  375. pcapkit/protocols/internet/icmpv6/__init__.py +40 -0
  376. pcapkit/protocols/internet/icmpv6/data.py +174 -0
  377. pcapkit/protocols/internet/icmpv6/protocol.py +735 -0
  378. pcapkit/protocols/internet/icmpv6/schema.py +144 -0
  379. pcapkit/protocols/internet/igmp/__init__.py +25 -0
  380. pcapkit/protocols/internet/igmp/data.py +59 -0
  381. pcapkit/protocols/internet/igmp/protocol.py +491 -0
  382. pcapkit/protocols/internet/igmp/schema.py +54 -0
  383. pcapkit/protocols/internet/igmpv1/__init__.py +14 -0
  384. pcapkit/protocols/internet/igmpv1/protocol.py +63 -0
  385. pcapkit/protocols/internet/igmpv2/__init__.py +14 -0
  386. pcapkit/protocols/internet/igmpv2/protocol.py +65 -0
  387. pcapkit/protocols/internet/igmpv3/__init__.py +32 -0
  388. pcapkit/protocols/internet/igmpv3/data.py +150 -0
  389. pcapkit/protocols/internet/igmpv3/protocol.py +587 -0
  390. pcapkit/protocols/internet/igmpv3/schema.py +373 -0
  391. pcapkit/protocols/internet/internet.py +566 -0
  392. pcapkit/protocols/internet/ip/__init__.py +14 -0
  393. pcapkit/protocols/internet/ip/protocol.py +205 -0
  394. pcapkit/protocols/internet/ipsec/__init__.py +14 -0
  395. pcapkit/protocols/internet/ipsec/protocol.py +48 -0
  396. pcapkit/protocols/internet/ipv4/__init__.py +68 -0
  397. pcapkit/protocols/internet/ipv4/data.py +470 -0
  398. pcapkit/protocols/internet/ipv4/protocol.py +2293 -0
  399. pcapkit/protocols/internet/ipv4/schema.py +747 -0
  400. pcapkit/protocols/internet/ipv6/__init__.py +25 -0
  401. pcapkit/protocols/internet/ipv6/data.py +83 -0
  402. pcapkit/protocols/internet/ipv6/protocol.py +731 -0
  403. pcapkit/protocols/internet/ipv6/schema.py +176 -0
  404. pcapkit/protocols/internet/ipv6_ext/__init__.py +25 -0
  405. pcapkit/protocols/internet/ipv6_ext/data.py +52 -0
  406. pcapkit/protocols/internet/ipv6_ext/protocol.py +718 -0
  407. pcapkit/protocols/internet/ipv6_ext/schema.py +397 -0
  408. pcapkit/protocols/internet/ipv6_frag/__init__.py +25 -0
  409. pcapkit/protocols/internet/ipv6_frag/data.py +41 -0
  410. pcapkit/protocols/internet/ipv6_frag/protocol.py +320 -0
  411. pcapkit/protocols/internet/ipv6_frag/schema.py +51 -0
  412. pcapkit/protocols/internet/ipv6_opts/__init__.py +83 -0
  413. pcapkit/protocols/internet/ipv6_opts/data.py +462 -0
  414. pcapkit/protocols/internet/ipv6_opts/protocol.py +2335 -0
  415. pcapkit/protocols/internet/ipv6_opts/schema.py +695 -0
  416. pcapkit/protocols/internet/ipv6_route/__init__.py +34 -0
  417. pcapkit/protocols/internet/ipv6_route/data.py +113 -0
  418. pcapkit/protocols/internet/ipv6_route/protocol.py +936 -0
  419. pcapkit/protocols/internet/ipv6_route/schema.py +299 -0
  420. pcapkit/protocols/internet/ipx/__init__.py +26 -0
  421. pcapkit/protocols/internet/ipx/data.py +59 -0
  422. pcapkit/protocols/internet/ipx/protocol.py +387 -0
  423. pcapkit/protocols/internet/ipx/schema.py +53 -0
  424. pcapkit/protocols/internet/mh/__init__.py +433 -0
  425. pcapkit/protocols/internet/mh/data.py +2464 -0
  426. pcapkit/protocols/internet/mh/protocol.py +11753 -0
  427. pcapkit/protocols/internet/mh/schema.py +3367 -0
  428. pcapkit/protocols/link/NotImplemented/dsl.py +0 -0
  429. pcapkit/protocols/link/NotImplemented/eapol.py +1 -0
  430. pcapkit/protocols/link/NotImplemented/fddi.py +0 -0
  431. pcapkit/protocols/link/NotImplemented/isdn.py +0 -0
  432. pcapkit/protocols/link/NotImplemented/ndp.py +0 -0
  433. pcapkit/protocols/link/NotImplemented/ppp.py +0 -0
  434. pcapkit/protocols/link/__init__.py +80 -0
  435. pcapkit/protocols/link/arp/__init__.py +27 -0
  436. pcapkit/protocols/link/arp/data.py +73 -0
  437. pcapkit/protocols/link/arp/protocol.py +513 -0
  438. pcapkit/protocols/link/arp/schema.py +49 -0
  439. pcapkit/protocols/link/c_tag/__init__.py +14 -0
  440. pcapkit/protocols/link/c_tag/protocol.py +99 -0
  441. pcapkit/protocols/link/ethernet/__init__.py +25 -0
  442. pcapkit/protocols/link/ethernet/data.py +27 -0
  443. pcapkit/protocols/link/ethernet/protocol.py +221 -0
  444. pcapkit/protocols/link/ethernet/schema.py +72 -0
  445. pcapkit/protocols/link/frad/__init__.py +25 -0
  446. pcapkit/protocols/link/frad/data.py +47 -0
  447. pcapkit/protocols/link/frad/protocol.py +470 -0
  448. pcapkit/protocols/link/frad/schema.py +112 -0
  449. pcapkit/protocols/link/gre/__init__.py +25 -0
  450. pcapkit/protocols/link/gre/data.py +64 -0
  451. pcapkit/protocols/link/gre/protocol.py +396 -0
  452. pcapkit/protocols/link/gre/schema.py +91 -0
  453. pcapkit/protocols/link/ieee802_11/__init__.py +30 -0
  454. pcapkit/protocols/link/ieee802_11/data.py +171 -0
  455. pcapkit/protocols/link/ieee802_11/protocol.py +612 -0
  456. pcapkit/protocols/link/ieee802_11/schema.py +163 -0
  457. pcapkit/protocols/link/inarp/__init__.py +14 -0
  458. pcapkit/protocols/link/inarp/protocol.py +55 -0
  459. pcapkit/protocols/link/l2tp/__init__.py +26 -0
  460. pcapkit/protocols/link/l2tp/data.py +72 -0
  461. pcapkit/protocols/link/l2tp/protocol.py +285 -0
  462. pcapkit/protocols/link/l2tp/schema.py +122 -0
  463. pcapkit/protocols/link/l2tpv2/__init__.py +14 -0
  464. pcapkit/protocols/link/l2tpv2/protocol.py +440 -0
  465. pcapkit/protocols/link/link.py +226 -0
  466. pcapkit/protocols/link/linux_sll/__init__.py +14 -0
  467. pcapkit/protocols/link/linux_sll/protocol.py +421 -0
  468. pcapkit/protocols/link/linux_sll1/__init__.py +25 -0
  469. pcapkit/protocols/link/linux_sll1/data.py +41 -0
  470. pcapkit/protocols/link/linux_sll1/protocol.py +247 -0
  471. pcapkit/protocols/link/linux_sll1/schema.py +46 -0
  472. pcapkit/protocols/link/linux_sll2/__init__.py +25 -0
  473. pcapkit/protocols/link/linux_sll2/data.py +47 -0
  474. pcapkit/protocols/link/linux_sll2/protocol.py +257 -0
  475. pcapkit/protocols/link/linux_sll2/schema.py +52 -0
  476. pcapkit/protocols/link/loopback/__init__.py +25 -0
  477. pcapkit/protocols/link/loopback/data.py +25 -0
  478. pcapkit/protocols/link/loopback/protocol.py +334 -0
  479. pcapkit/protocols/link/loopback/schema.py +33 -0
  480. pcapkit/protocols/link/netlink/__init__.py +25 -0
  481. pcapkit/protocols/link/netlink/data.py +40 -0
  482. pcapkit/protocols/link/netlink/protocol.py +390 -0
  483. pcapkit/protocols/link/netlink/schema.py +44 -0
  484. pcapkit/protocols/link/radiotap/__init__.py +103 -0
  485. pcapkit/protocols/link/radiotap/data.py +768 -0
  486. pcapkit/protocols/link/radiotap/protocol.py +2264 -0
  487. pcapkit/protocols/link/radiotap/schema.py +662 -0
  488. pcapkit/protocols/link/s_tag/__init__.py +14 -0
  489. pcapkit/protocols/link/s_tag/protocol.py +102 -0
  490. pcapkit/protocols/link/vlan/__init__.py +27 -0
  491. pcapkit/protocols/link/vlan/data.py +47 -0
  492. pcapkit/protocols/link/vlan/protocol.py +269 -0
  493. pcapkit/protocols/link/vlan/schema.py +77 -0
  494. pcapkit/protocols/misc/__init__.py +60 -0
  495. pcapkit/protocols/misc/checksum/__init__.py +28 -0
  496. pcapkit/protocols/misc/checksum/ip_pseudo/__init__.py +25 -0
  497. pcapkit/protocols/misc/checksum/ip_pseudo/data.py +41 -0
  498. pcapkit/protocols/misc/checksum/ip_pseudo/protocol.py +692 -0
  499. pcapkit/protocols/misc/checksum/ip_pseudo/schema.py +118 -0
  500. pcapkit/protocols/misc/no_payload/__init__.py +25 -0
  501. pcapkit/protocols/misc/no_payload/data.py +17 -0
  502. pcapkit/protocols/misc/no_payload/protocol.py +164 -0
  503. pcapkit/protocols/misc/no_payload/schema.py +17 -0
  504. pcapkit/protocols/misc/pcap/__init__.py +30 -0
  505. pcapkit/protocols/misc/pcap/frame/__init__.py +26 -0
  506. pcapkit/protocols/misc/pcap/frame/data.py +62 -0
  507. pcapkit/protocols/misc/pcap/frame/protocol.py +673 -0
  508. pcapkit/protocols/misc/pcap/frame/schema.py +47 -0
  509. pcapkit/protocols/misc/pcap/header/__init__.py +26 -0
  510. pcapkit/protocols/misc/pcap/header/data.py +52 -0
  511. pcapkit/protocols/misc/pcap/header/protocol.py +391 -0
  512. pcapkit/protocols/misc/pcap/header/schema.py +103 -0
  513. pcapkit/protocols/misc/pcapng/__init__.py +160 -0
  514. pcapkit/protocols/misc/pcapng/data.py +1102 -0
  515. pcapkit/protocols/misc/pcapng/protocol.py +6960 -0
  516. pcapkit/protocols/misc/pcapng/schema.py +2825 -0
  517. pcapkit/protocols/misc/raw/__init__.py +25 -0
  518. pcapkit/protocols/misc/raw/data.py +35 -0
  519. pcapkit/protocols/misc/raw/protocol.py +188 -0
  520. pcapkit/protocols/misc/raw/schema.py +24 -0
  521. pcapkit/protocols/protocol.py +3145 -0
  522. pcapkit/protocols/schema.py +1295 -0
  523. pcapkit/protocols/transport/NotImplemented/rsvp.py +0 -0
  524. pcapkit/protocols/transport/__init__.py +47 -0
  525. pcapkit/protocols/transport/dccp/__init__.py +57 -0
  526. pcapkit/protocols/transport/dccp/data.py +275 -0
  527. pcapkit/protocols/transport/dccp/protocol.py +1525 -0
  528. pcapkit/protocols/transport/dccp/schema.py +381 -0
  529. pcapkit/protocols/transport/sctp/__init__.py +147 -0
  530. pcapkit/protocols/transport/sctp/data.py +633 -0
  531. pcapkit/protocols/transport/sctp/protocol.py +3937 -0
  532. pcapkit/protocols/transport/sctp/schema.py +1007 -0
  533. pcapkit/protocols/transport/tcp/__init__.py +108 -0
  534. pcapkit/protocols/transport/tcp/data.py +637 -0
  535. pcapkit/protocols/transport/tcp/protocol.py +3640 -0
  536. pcapkit/protocols/transport/tcp/schema.py +1131 -0
  537. pcapkit/protocols/transport/transport.py +371 -0
  538. pcapkit/protocols/transport/udp/__init__.py +25 -0
  539. pcapkit/protocols/transport/udp/data.py +38 -0
  540. pcapkit/protocols/transport/udp/protocol.py +384 -0
  541. pcapkit/protocols/transport/udp/schema.py +44 -0
  542. pcapkit/py.typed +0 -0
  543. pcapkit/toolkit/__init__.py +88 -0
  544. pcapkit/toolkit/dpkt.py +909 -0
  545. pcapkit/toolkit/pcap.py +510 -0
  546. pcapkit/toolkit/pcap_ct.py +160 -0
  547. pcapkit/toolkit/pcapng.py +287 -0
  548. pcapkit/toolkit/pypcap.py +158 -0
  549. pcapkit/toolkit/pypcapfile.py +917 -0
  550. pcapkit/toolkit/pyshark.py +628 -0
  551. pcapkit/toolkit/scapy.py +761 -0
  552. pcapkit/utilities/__init__.py +41 -0
  553. pcapkit/utilities/chardet.py +64 -0
  554. pcapkit/utilities/compat.py +173 -0
  555. pcapkit/utilities/config.py +446 -0
  556. pcapkit/utilities/contextvars.py +57 -0
  557. pcapkit/utilities/datetime.py +117 -0
  558. pcapkit/utilities/exceptions.py +845 -0
  559. pcapkit/utilities/importlib.py +123 -0
  560. pcapkit/utilities/inspect.py +55 -0
  561. pcapkit/utilities/logging.py +395 -0
  562. pcapkit/utilities/pickle.py +181 -0
  563. pcapkit/utilities/warnings.py +538 -0
  564. pcapkit/vendor/__init__.py +220 -0
  565. pcapkit/vendor/__main__.py +253 -0
  566. pcapkit/vendor/arp/__init__.py +27 -0
  567. pcapkit/vendor/arp/hardware.py +29 -0
  568. pcapkit/vendor/arp/operation.py +29 -0
  569. pcapkit/vendor/dccp/__init__.py +44 -0
  570. pcapkit/vendor/dccp/ack_vector_state.py +29 -0
  571. pcapkit/vendor/dccp/drop_code.py +29 -0
  572. pcapkit/vendor/dccp/feature.py +29 -0
  573. pcapkit/vendor/dccp/option.py +29 -0
  574. pcapkit/vendor/dccp/packet_type.py +29 -0
  575. pcapkit/vendor/dccp/reset_code.py +29 -0
  576. pcapkit/vendor/default.py +823 -0
  577. pcapkit/vendor/esp/__init__.py +32 -0
  578. pcapkit/vendor/esp/cipher.py +114 -0
  579. pcapkit/vendor/esp/integrity.py +111 -0
  580. pcapkit/vendor/ftp/__init__.py +27 -0
  581. pcapkit/vendor/ftp/command.py +577 -0
  582. pcapkit/vendor/ftp/return_code.py +363 -0
  583. pcapkit/vendor/hip/__init__.py +94 -0
  584. pcapkit/vendor/hip/certificate.py +29 -0
  585. pcapkit/vendor/hip/cipher.py +29 -0
  586. pcapkit/vendor/hip/di.py +29 -0
  587. pcapkit/vendor/hip/ecdsa_curve.py +29 -0
  588. pcapkit/vendor/hip/ecdsa_low_curve.py +29 -0
  589. pcapkit/vendor/hip/eddsa_curve.py +85 -0
  590. pcapkit/vendor/hip/esp_transform_suite.py +29 -0
  591. pcapkit/vendor/hip/group.py +87 -0
  592. pcapkit/vendor/hip/hi_algorithm.py +29 -0
  593. pcapkit/vendor/hip/hit_suite.py +29 -0
  594. pcapkit/vendor/hip/nat_traversal.py +29 -0
  595. pcapkit/vendor/hip/notify_message.py +29 -0
  596. pcapkit/vendor/hip/packet.py +88 -0
  597. pcapkit/vendor/hip/parameter.py +88 -0
  598. pcapkit/vendor/hip/registration.py +29 -0
  599. pcapkit/vendor/hip/registration_failure.py +29 -0
  600. pcapkit/vendor/hip/suite.py +29 -0
  601. pcapkit/vendor/hip/transport.py +29 -0
  602. pcapkit/vendor/http/__init__.py +39 -0
  603. pcapkit/vendor/http/error_code.py +94 -0
  604. pcapkit/vendor/http/frame.py +91 -0
  605. pcapkit/vendor/http/method.py +309 -0
  606. pcapkit/vendor/http/setting.py +93 -0
  607. pcapkit/vendor/http/status_code.py +233 -0
  608. pcapkit/vendor/icmp/__init__.py +40 -0
  609. pcapkit/vendor/icmp/destination_unreachable_code.py +80 -0
  610. pcapkit/vendor/icmp/parameter_problem_code.py +80 -0
  611. pcapkit/vendor/icmp/time_exceeded_code.py +80 -0
  612. pcapkit/vendor/icmp/type.py +78 -0
  613. pcapkit/vendor/icmpv6/__init__.py +40 -0
  614. pcapkit/vendor/icmpv6/destination_unreachable_code.py +80 -0
  615. pcapkit/vendor/icmpv6/parameter_problem_code.py +80 -0
  616. pcapkit/vendor/icmpv6/time_exceeded_code.py +73 -0
  617. pcapkit/vendor/icmpv6/type.py +78 -0
  618. pcapkit/vendor/ieee802_11/__init__.py +54 -0
  619. pcapkit/vendor/ieee802_11/control_subtype.py +107 -0
  620. pcapkit/vendor/ieee802_11/data_subtype.py +106 -0
  621. pcapkit/vendor/ieee802_11/extension_subtype.py +95 -0
  622. pcapkit/vendor/ieee802_11/management_subtype.py +102 -0
  623. pcapkit/vendor/ieee802_11/type.py +90 -0
  624. pcapkit/vendor/igmp/__init__.py +27 -0
  625. pcapkit/vendor/igmp/record_type.py +88 -0
  626. pcapkit/vendor/igmp/type.py +77 -0
  627. pcapkit/vendor/ipv4/__init__.py +59 -0
  628. pcapkit/vendor/ipv4/classification_level.py +90 -0
  629. pcapkit/vendor/ipv4/option_class.py +80 -0
  630. pcapkit/vendor/ipv4/option_number.py +105 -0
  631. pcapkit/vendor/ipv4/protection_authority.py +84 -0
  632. pcapkit/vendor/ipv4/qs_function.py +78 -0
  633. pcapkit/vendor/ipv4/router_alert.py +94 -0
  634. pcapkit/vendor/ipv4/tos_del.py +78 -0
  635. pcapkit/vendor/ipv4/tos_ecn.py +95 -0
  636. pcapkit/vendor/ipv4/tos_pre.py +84 -0
  637. pcapkit/vendor/ipv4/tos_rel.py +78 -0
  638. pcapkit/vendor/ipv4/tos_thr.py +78 -0
  639. pcapkit/vendor/ipv4/ts_flag.py +79 -0
  640. pcapkit/vendor/ipv6/__init__.py +53 -0
  641. pcapkit/vendor/ipv6/extension_header.py +220 -0
  642. pcapkit/vendor/ipv6/option.py +104 -0
  643. pcapkit/vendor/ipv6/option_action.py +90 -0
  644. pcapkit/vendor/ipv6/qs_function.py +78 -0
  645. pcapkit/vendor/ipv6/router_alert.py +93 -0
  646. pcapkit/vendor/ipv6/routing.py +87 -0
  647. pcapkit/vendor/ipv6/seed_id.py +81 -0
  648. pcapkit/vendor/ipv6/smf_dpd_mode.py +78 -0
  649. pcapkit/vendor/ipv6/tagger_id.py +81 -0
  650. pcapkit/vendor/ipx/__init__.py +39 -0
  651. pcapkit/vendor/ipx/packet.py +149 -0
  652. pcapkit/vendor/ipx/socket.py +240 -0
  653. pcapkit/vendor/l2tp/__init__.py +21 -0
  654. pcapkit/vendor/l2tp/type.py +79 -0
  655. pcapkit/vendor/linux/__init__.py +21 -0
  656. pcapkit/vendor/linux/arphrd.py +100 -0
  657. pcapkit/vendor/mh/__init__.py +206 -0
  658. pcapkit/vendor/mh/access_type.py +87 -0
  659. pcapkit/vendor/mh/ack_status_code.py +88 -0
  660. pcapkit/vendor/mh/ani_suboption.py +88 -0
  661. pcapkit/vendor/mh/auth_subtype.py +83 -0
  662. pcapkit/vendor/mh/binding_ack_flag.py +164 -0
  663. pcapkit/vendor/mh/binding_error.py +78 -0
  664. pcapkit/vendor/mh/binding_revocation.py +87 -0
  665. pcapkit/vendor/mh/binding_update_flag.py +163 -0
  666. pcapkit/vendor/mh/cga_extension.py +91 -0
  667. pcapkit/vendor/mh/cga_sec.py +91 -0
  668. pcapkit/vendor/mh/cga_type.py +74 -0
  669. pcapkit/vendor/mh/dhcp_support_mode.py +77 -0
  670. pcapkit/vendor/mh/dns_status_code.py +87 -0
  671. pcapkit/vendor/mh/dsmip6_tls_packet.py +87 -0
  672. pcapkit/vendor/mh/dsmipv6_home_address.py +87 -0
  673. pcapkit/vendor/mh/enumerating_algorithm.py +82 -0
  674. pcapkit/vendor/mh/fb_ack_status.py +87 -0
  675. pcapkit/vendor/mh/fb_action.py +88 -0
  676. pcapkit/vendor/mh/fb_indication_trigger.py +87 -0
  677. pcapkit/vendor/mh/fb_type.py +88 -0
  678. pcapkit/vendor/mh/flow_id_status.py +87 -0
  679. pcapkit/vendor/mh/flow_id_suboption.py +87 -0
  680. pcapkit/vendor/mh/handoff_type.py +87 -0
  681. pcapkit/vendor/mh/handover_ack_flag.py +159 -0
  682. pcapkit/vendor/mh/handover_ack_status.py +87 -0
  683. pcapkit/vendor/mh/handover_initiate_flag.py +159 -0
  684. pcapkit/vendor/mh/handover_initiate_status.py +87 -0
  685. pcapkit/vendor/mh/home_address_reply.py +87 -0
  686. pcapkit/vendor/mh/lla_code.py +97 -0
  687. pcapkit/vendor/mh/lma_mag_suboption.py +88 -0
  688. pcapkit/vendor/mh/mn_group_id.py +87 -0
  689. pcapkit/vendor/mh/mn_id_subtype.py +87 -0
  690. pcapkit/vendor/mh/operator_id.py +87 -0
  691. pcapkit/vendor/mh/option.py +83 -0
  692. pcapkit/vendor/mh/packet.py +82 -0
  693. pcapkit/vendor/mh/qos_attribute.py +87 -0
  694. pcapkit/vendor/mh/revocation_status_code.py +87 -0
  695. pcapkit/vendor/mh/revocation_trigger.py +87 -0
  696. pcapkit/vendor/mh/status_code.py +91 -0
  697. pcapkit/vendor/mh/traffic_selector.py +87 -0
  698. pcapkit/vendor/mh/upa_status.py +87 -0
  699. pcapkit/vendor/mh/upn_reason.py +87 -0
  700. pcapkit/vendor/ngap/__init__.py +31 -0
  701. pcapkit/vendor/ngap/procedure_code.py +233 -0
  702. pcapkit/vendor/ngap/protocol_ie.py +201 -0
  703. pcapkit/vendor/ospf/__init__.py +27 -0
  704. pcapkit/vendor/ospf/authentication.py +29 -0
  705. pcapkit/vendor/ospf/packet.py +29 -0
  706. pcapkit/vendor/pcapng/__init__.py +55 -0
  707. pcapkit/vendor/pcapng/block_type.py +102 -0
  708. pcapkit/vendor/pcapng/filter_type.py +77 -0
  709. pcapkit/vendor/pcapng/hash_algorithm.py +82 -0
  710. pcapkit/vendor/pcapng/option_type.py +477 -0
  711. pcapkit/vendor/pcapng/record_type.py +81 -0
  712. pcapkit/vendor/pcapng/secrets_type.py +80 -0
  713. pcapkit/vendor/pcapng/tls_key_label.py +180 -0
  714. pcapkit/vendor/pcapng/verdict_type.py +79 -0
  715. pcapkit/vendor/radiotap/__init__.py +86 -0
  716. pcapkit/vendor/radiotap/ampdu_flags.py +46 -0
  717. pcapkit/vendor/radiotap/channel_flags.py +51 -0
  718. pcapkit/vendor/radiotap/eht_known.py +59 -0
  719. pcapkit/vendor/radiotap/field_type.py +151 -0
  720. pcapkit/vendor/radiotap/flags.py +307 -0
  721. pcapkit/vendor/radiotap/he_data1_known.py +54 -0
  722. pcapkit/vendor/radiotap/he_data2_known.py +49 -0
  723. pcapkit/vendor/radiotap/he_mu_flags1_known.py +48 -0
  724. pcapkit/vendor/radiotap/he_mu_flags2_known.py +42 -0
  725. pcapkit/vendor/radiotap/he_mu_other_user_known.py +38 -0
  726. pcapkit/vendor/radiotap/lsig_data1.py +40 -0
  727. pcapkit/vendor/radiotap/mcs_known.py +48 -0
  728. pcapkit/vendor/radiotap/rx_flags.py +39 -0
  729. pcapkit/vendor/radiotap/s1g_known.py +46 -0
  730. pcapkit/vendor/radiotap/timestamp_flags.py +40 -0
  731. pcapkit/vendor/radiotap/tx_flags.py +44 -0
  732. pcapkit/vendor/radiotap/usig_common_known.py +48 -0
  733. pcapkit/vendor/radiotap/vht_coding.py +42 -0
  734. pcapkit/vendor/radiotap/vht_flags.py +44 -0
  735. pcapkit/vendor/radiotap/vht_known.py +47 -0
  736. pcapkit/vendor/reg/__init__.py +47 -0
  737. pcapkit/vendor/reg/apptype/__init__.py +36 -0
  738. pcapkit/vendor/reg/apptype/apptype.py +1320 -0
  739. pcapkit/vendor/reg/apptype/dccp.py +27 -0
  740. pcapkit/vendor/reg/apptype/sctp.py +27 -0
  741. pcapkit/vendor/reg/apptype/tcp.py +27 -0
  742. pcapkit/vendor/reg/apptype/udp.py +27 -0
  743. pcapkit/vendor/reg/ethertype.py +175 -0
  744. pcapkit/vendor/reg/linktype.py +210 -0
  745. pcapkit/vendor/reg/transtype.py +116 -0
  746. pcapkit/vendor/sctp/__init__.py +37 -0
  747. pcapkit/vendor/sctp/cause_code.py +29 -0
  748. pcapkit/vendor/sctp/chunk.py +29 -0
  749. pcapkit/vendor/sctp/parameter.py +29 -0
  750. pcapkit/vendor/sctp/payload_protocol_identifier.py +34 -0
  751. pcapkit/vendor/sslv2/__init__.py +24 -0
  752. pcapkit/vendor/sslv2/handshake_type.py +100 -0
  753. pcapkit/vendor/sslv2/version.py +95 -0
  754. pcapkit/vendor/tcp/__init__.py +35 -0
  755. pcapkit/vendor/tcp/checksum.py +80 -0
  756. pcapkit/vendor/tcp/flags.py +180 -0
  757. pcapkit/vendor/tcp/mp_tcp_option.py +90 -0
  758. pcapkit/vendor/tcp/option.py +103 -0
  759. pcapkit/vendor/tls/__init__.py +30 -0
  760. pcapkit/vendor/tls/content_type.py +142 -0
  761. pcapkit/vendor/tls/extension_type.py +151 -0
  762. pcapkit/vendor/tls/handshake_type.py +154 -0
  763. pcapkit/vendor/vlan/__init__.py +23 -0
  764. pcapkit/vendor/vlan/priority_level.py +97 -0
  765. pypcapkit-1.6.2.dist-info/METADATA +199 -0
  766. pypcapkit-1.6.2.dist-info/RECORD +770 -0
  767. pypcapkit-1.6.2.dist-info/WHEEL +5 -0
  768. pypcapkit-1.6.2.dist-info/entry_points.txt +3 -0
  769. pypcapkit-1.6.2.dist-info/licenses/LICENSE +29 -0
  770. pypcapkit-1.6.2.dist-info/top_level.txt +1 -0
@@ -0,0 +1,742 @@
1
+ # -*- coding: utf-8 -*-
2
+ """Constant Enumeration Base
3
+ ===============================
4
+
5
+ .. module:: pcapkit.corekit.enum
6
+
7
+ :mod:`pcapkit.corekit.enum` contains the bases every enumeration in this
8
+ library inherits from, split by whether the enumeration may *grow*:
9
+
10
+ * :class:`EnumLookup` -- the **lookup** half: :meth:`~EnumLookup.get`,
11
+ :meth:`~EnumLookup.get_all` and the overridable
12
+ :meth:`~EnumLookup._validate_value` guard. It mutates nothing, so a *closed*
13
+ set inherits it without a contract it must refuse.
14
+ * :class:`EnumRegistry`, its subclass -- adds the **mutating** half:
15
+ :meth:`~EnumRegistry.register`, :meth:`~EnumRegistry.register_alias`,
16
+ :meth:`~EnumRegistry.register_aliases`, :meth:`~EnumRegistry._extend` and
17
+ :meth:`~EnumRegistry._unregistered_member`. Every generated registry under
18
+ :mod:`pcapkit.const` inherits from it.
19
+
20
+ A helper enumeration is closed unless RFC or IANA documents its value space as
21
+ open (:issue:`877`). Every mutating method stays on :class:`EnumRegistry`: a
22
+ base carrying ``register`` has no principled reason to withhold
23
+ ``register_alias``, and one holding both would leave :class:`EnumRegistry` too
24
+ thin to justify a second class. The base carries range validation instead,
25
+ :meth:`EnumLookup._validate_value`: legality is every enumeration's concern,
26
+ mutation only the open registries'.
27
+
28
+ The registry contracts are :issue:`842`'s: ``get`` is a shortcut for ``[]``
29
+ and returns the canonical member; ``get_all`` returns every matching member;
30
+ ``register`` mints a member at runtime under the name the caller gives; and
31
+ ``register_alias`` (and ``register_aliases``) adds alias names to a member.
32
+ Defining them here rather than as generated text in
33
+ :data:`pcapkit.vendor.default.LINE` means adding a method edits one class, not
34
+ every crawler template that replaces it (:issue:`775`).
35
+
36
+ The registry tiers, with :class:`~pcapkit.const.reg.apptype.apptype.AppType`
37
+ layered on top (:issue:`860`):
38
+
39
+ 1. :class:`EnumRegistry` -- the form for a registry mapping one key to one
40
+ member, which a registry under :mod:`pcapkit.const` uses as is unless it
41
+ carries a hand-written ``get`` override.
42
+ 2. :class:`~pcapkit.const.reg.apptype.apptype.AppType`, mixing in
43
+ :class:`EnumRegistry` directly -- routes ``get`` and ``get_all`` through its
44
+ ``_dispatch``, since a port lookup needs a transport protocol. Its
45
+ ``register`` and ``register_alias`` skip that dispatch and stay on the
46
+ registry they are called on, so a write never leaks onto a transport IANA
47
+ never assigned the service to. Its ``_unregistered_member`` also sets
48
+ ``svc``, ``port`` and ``proto``.
49
+ 3. Its transport subclasses -- :class:`~pcapkit.const.reg.apptype.tcp.TCP`,
50
+ :class:`~pcapkit.const.reg.apptype.udp.UDP`,
51
+ :class:`~pcapkit.const.reg.apptype.sctp.SCTP` and
52
+ :class:`~pcapkit.const.reg.apptype.dccp.DCCP` -- override nothing:
53
+ ``_dispatch`` returns ``cls`` unchanged once ``cls.__registry__`` is not
54
+ :obj:`None`, which holds for exactly these.
55
+
56
+ .. versionadded:: 1.5.0
57
+
58
+ The ``get`` each :mod:`pcapkit.const` enumeration carried as generated text
59
+ moves onto :class:`EnumLookup`, and :class:`EnumRegistry` adds ``register``,
60
+ which is how a member is minted at runtime: outside :class:`~pcapkit.const.mh.cga_type.CGAType`, looking up
61
+ an unknown value does not mint one (:issue:`775`).
62
+
63
+ """
64
+ from typing import TYPE_CHECKING
65
+
66
+ from aenum import extend_enum
67
+
68
+ from pcapkit.corekit.sentinels import NO_DEFAULT
69
+ from pcapkit.utilities.exceptions import BaseError, CaughtByCaller, EnumKeyError, EnumValueError
70
+ from pcapkit.utilities.pickle import reduce_to
71
+
72
+ if TYPE_CHECKING:
73
+ from typing import Any, Type
74
+
75
+ from typing_extensions import Self
76
+
77
+ __all__ = ['EnumLookup', 'EnumRegistry']
78
+
79
+
80
+ class EnumLookup:
81
+ """Bare lookup protocol, shared by open registries and closed sets alike.
82
+
83
+ Carries :meth:`get`, :meth:`get_all` and the :meth:`_validate_value` guard --
84
+ everything an enumeration needs in order to be *read* by name or by value,
85
+ and nothing that could grow it. :class:`EnumRegistry` adds the mutating half
86
+ on top; a closed enumeration inherits this one directly and so is never
87
+ handed a ``register`` it would have to refuse.
88
+
89
+ This is a plain mix-in rather than an ``aenum.Enum`` subclass, because
90
+ an enumeration that already has members cannot be subclassed. Mixed in
91
+ *before* the member type -- ``class Foo(EnumRegistry, IntFlag)``, or
92
+ ``class Bar(EnumLookup, IntEnum)`` -- it contributes methods only, so
93
+ |aenum|_ still resolves the member data type from the enumeration base:
94
+ ``int`` for ``aenum.IntEnum`` and ``aenum.IntFlag``, ``str`` for
95
+ ``aenum.StrEnum``. That is what lets one base serve each of them, where a
96
+ generated template fragment would have needed a separate rendering per
97
+ member type.
98
+
99
+ Because both tiers are plain classes, inserting this one *above*
100
+ :class:`EnumRegistry` leaves the member data type exactly where it was:
101
+ ``class Foo(EnumRegistry, IntFlag)`` resolves as ``Foo -> EnumRegistry ->
102
+ EnumLookup -> IntFlag -> int -> ...``, so ``_member_type_`` still comes from
103
+ the enumeration base and not from anything in this module. Had this tier
104
+ subclassed ``aenum.Enum`` in order to "be an enum", it would have
105
+ become the member type itself and broken every one of these shapes at once.
106
+
107
+ The methods deliberately touch only ``_member_map_``, ``_member_names_`` and
108
+ ``_value2member_map_``, which both :mod:`enum` and |aenum|_ maintain, so
109
+ nothing on this tier depends on |aenum|_ internals at all -- the
110
+ ``aenum.extend_enum`` call in this module belongs to
111
+ :class:`EnumRegistry`, which is the tier that mutates.
112
+
113
+ """
114
+
115
+ if TYPE_CHECKING:
116
+ #: The enumeration machinery's own lookup tables and member data type,
117
+ #: declared here because they are contributed by the ``aenum.Enum``
118
+ #: base this mix-in is combined with rather than by the mix-in itself.
119
+ _member_map_: 'dict[str, Self]'
120
+ _member_names_: 'list[str]'
121
+ _value2member_map_: 'dict[Any, Self]'
122
+ # NOTE: ``Any``, not ``type``, as a precise type makes mypy read
123
+ # ``cls._member_type_.__new__(cls, value)`` as building a class, not an instance.
124
+ _member_type_: 'Any'
125
+
126
+ @classmethod
127
+ def _validate_value(cls, value: 'Any') -> 'None':
128
+ """Hook: reject ``value`` if this enumeration's contract does not allow it.
129
+
130
+ GitHub issue :issue:`877` requires some range-validation logic for the
131
+ inheriting classes to hook into. This is that hook, and it is what the
132
+ bare tier carries **instead** of ``register``: what values are *legal*
133
+ is something every enumeration has an opinion on, whereas who may *add*
134
+ one is only an open registry's concern.
135
+
136
+ The base implementation accepts everything, because a base cannot know
137
+ any subclass's range. Overriding it is how a subclass states one, and
138
+ every registry under :mod:`pcapkit.const` does, its vendor generator
139
+ emitting the check its ``_missing_`` makes (:issue:`1816`) -- in the
140
+ shape::
141
+
142
+ @classmethod
143
+ def _validate_value(cls, value: 'Any') -> 'None':
144
+ if not (isinstance(value, int) and 0 <= value <= 0xFF):
145
+ raise EnumValueError(f'{value!r} is not a valid {cls.__name__}')
146
+
147
+ An override **raises or returns**; it must never *normalise*. The return
148
+ type is :obj:`None` deliberately rather than the validated value, so that
149
+ this hook cannot become a converter: a subclass that returned a changed
150
+ value here would silently alter what a lookup resolves to, which is
151
+ exactly the case-folding the ruling on GitHub issue :issue:`877` rules
152
+ out: an enumeration keeps the original spellings its registrars use. Case
153
+ handling belongs in a deliberate ``get`` override with an RFC behind it,
154
+ not in a validation hook.
155
+
156
+ Raise from :mod:`pcapkit.utilities.exceptions`, per the same issue's
157
+ ruling that in-library code raises in-library exceptions --
158
+ :exc:`~pcapkit.utilities.exceptions.EnumValueError` is the fitting one
159
+ and is already what the closed enumerations in
160
+ :mod:`pcapkit.protocols.internet.mh.protocol` raise. Note what that buys on the
161
+ :meth:`get` path: :exc:`~pcapkit.utilities.exceptions.EnumValueError`
162
+ subclasses :exc:`ValueError`, so a rejection here is caught by
163
+ :meth:`get`'s own ``except ValueError`` and falls back to ``default``
164
+ just as any other unresolvable value does. It is also quiet:
165
+ :meth:`get` always calls this hook inside a
166
+ :class:`~pcapkit.utilities.exceptions.CaughtByCaller` block for
167
+ :exc:`ValueError`, so an override need not pass ``quiet=True`` for its
168
+ rejection to log nothing there (:issue:`1845`). An override raising
169
+ something outside that hierarchy would instead propagate past
170
+ ``default``, unquieted, which is a real difference in behaviour rather
171
+ than a stylistic preference. With no usable ``default``, a rejection
172
+ from this hook reaches the caller exactly as the override raised it --
173
+ :meth:`get` re-raises an in-library ``ValueError`` unchanged rather than
174
+ re-wrapping it, so the override's own message is what the caller sees.
175
+
176
+ Called from the places below, and the omissions are deliberate:
177
+
178
+ * :meth:`get`, immediately before ``cls(key)`` -- the one point at which
179
+ a lookup can reach a subclass's ``_missing_`` and mint. The ``str``-key
180
+ path does **not** call it, because that path never calls ``cls(key)``:
181
+ it resolves against the already-populated lookup tables only, where
182
+ every value present is legal by construction, so there is nothing left
183
+ to validate.
184
+ * :meth:`EnumRegistry.register`, before minting -- the one point at which
185
+ a caller can introduce a value no member carries yet. Its rejection
186
+ stays loud even when ``register`` runs inside :meth:`get`'s quiet
187
+ block, since a refused mint is a fault to report rather than a
188
+ lookup that missed.
189
+
190
+ Of the registries that override :meth:`EnumRegistry.register` to mint
191
+ through a path of their own,
192
+ :meth:`OptionType.register <pcapkit.const.pcapng.option_type.OptionType.register>`
193
+ and
194
+ :meth:`AppType.register <pcapkit.const.reg.apptype.apptype.AppType.register>`
195
+ each call it at the same point.
196
+
197
+ :meth:`EnumRegistry.register_alias` does not call it, and does not need
198
+ to: it refuses any ``value`` that is not already registered, so the value
199
+ it aliases has necessarily passed validation already.
200
+ :meth:`EnumRegistry._unregistered_member` does not call it either,
201
+ because its callers are the subclasses' own ``_missing_`` bodies, which
202
+ already range-check before delegating here -- validating again would
203
+ double the check without being able to disagree with it.
204
+
205
+ Deliberately carries no ``Raises:`` clause, because this implementation
206
+ raises nothing at all -- an override is what raises, and documenting an
207
+ exception here that this body cannot produce is exactly the phantom
208
+ :class:`tests.test_docstring_contract.DocstringRaisesTests` rejects.
209
+ An override adds its own clause naming what *it* rejects.
210
+
211
+ Args:
212
+ value: Candidate value to check.
213
+
214
+ Returns:
215
+ Nothing. A value this enumeration allows is reported by returning
216
+ normally; a value it does not is reported by raising.
217
+
218
+ """
219
+
220
+ @classmethod
221
+ def get(cls, key: 'Any', default: 'Any' = NO_DEFAULT) -> 'Self':
222
+ """Resolve ``key`` to the canonical member.
223
+
224
+ A shortcut for the ``[]`` operation, per the ruling on :issue:`842`:
225
+ given a name it is ``cls[key]``, and given a value it is
226
+ ``cls(key)``. Either way the answer is the *canonical* member --
227
+ subscripting an alias returns the member the alias points at, not a
228
+ separate object -- so two names for one assignment resolve to one
229
+ enum.
230
+
231
+ It never mints while resolving ``default``; ``key`` may still mint
232
+ through a ``_missing_`` that GitHub issue :issue:`775`'s ruling
233
+ deliberately kept minting, on :class:`~pcapkit.const.mh.cga_type.CGAType`. Registering a
234
+ member any other way is :meth:`~EnumRegistry.register`'s job and nobody else's, which is the ruling
235
+ :issue:`775` exists to carry
236
+ out: an unrecognised or unregistered value does not become a registered
237
+ member unless a user or caller explicitly creates one. A value inside a
238
+ registry's declared-but-unassigned range still resolves, through that
239
+ registry's own ``_missing_`` and :meth:`~EnumRegistry._unregistered_member`, to a
240
+ member that is deliberately absent from the lookup tables -- true
241
+ outside :class:`~pcapkit.const.mh.cga_type.CGAType`, where such a value instead lands
242
+ in *both* tables, exactly as :meth:`~EnumRegistry.register` would leave it -- for a
243
+ non-``str`` key; the ``str`` case is qualified below. Both describe
244
+ ``key`` resolution only. ``default`` never reaches ``_missing_`` on
245
+ either branch: a declared-but-unassigned ``default`` does not resolve
246
+ to an unregistered member the way such a ``key`` does -- it simply does
247
+ not resolve, and the lookup error ``key`` itself would have raised
248
+ propagates instead.
249
+
250
+ For a ``str`` key, a name match wins over a value match -- the two are
251
+ checked in that order, so a string that happens to be both a member's
252
+ name and a *different* member's value resolves to the name's member.
253
+ The value side of that check is a plain ``_value2member_map_`` lookup,
254
+ not ``cls(key)``: on a registry whose own ``_missing_`` mints for an
255
+ unrecognised value, routing a failed *name* lookup through the
256
+ constructor would let a mere ``get()`` call mint a permanent member
257
+ where it should just raise. Defensive rather than observed: none of
258
+ the ``str``-valued registries that reach this method
259
+ (:class:`~pcapkit.const.ftp.command.Command`,
260
+ :class:`~pcapkit.const.ftp.command.FEATCode`, :class:`~pcapkit.const.http.method.Method`,
261
+ :class:`~pcapkit.const.pcapng.option_type.OptionType`,
262
+ :class:`~pcapkit.const.reg.apptype.apptype.AppType` and its
263
+ transport subclasses :class:`~pcapkit.const.reg.apptype.tcp.TCP`,
264
+ :class:`~pcapkit.const.reg.apptype.udp.UDP`,
265
+ :class:`~pcapkit.const.reg.apptype.sctp.SCTP` and
266
+ :class:`~pcapkit.const.reg.apptype.dccp.DCCP`, and
267
+ :class:`~pcapkit.const.pcapng.tls_key_label.TLSKeyLabel`) mints on
268
+ any path, so no live witness exists in this tree.
269
+ :class:`~pcapkit.const.mh.cga_type.CGAType`, which still mints directly
270
+ via ``aenum.extend_enum``, is :class:`int`-valued, so
271
+ a ``str`` name could not reach its mint branch even if this restriction
272
+ did not exist; it is not an exception to it, just not reachable by it.
273
+ This is about a future ``str``-valued registry (or a present one whose
274
+ ``_missing_`` someday changes) reaching this base with a minting
275
+ ``_missing_`` of its own, which the restriction below is written to
276
+ stay correct for regardless. Restricting the value side of ``key`` to
277
+ an already-registered value keeps *that side* non-minting on every
278
+ ``str``-valued registry, not only the ones without a minting
279
+ ``_missing_``; and ``default`` resolves through the same kind of
280
+ ``_value2member_map_`` lookup rather than ``cls(default)``
281
+ (:issue:`864`), so for a ``str`` key every path through this method --
282
+ name, value and ``default`` alike -- is non-minting.
283
+
284
+ That restriction has a cost the paragraph above glosses over: a
285
+ *declared-but-unassigned* value -- the case resolved there through
286
+ ``_missing_`` and :meth:`~EnumRegistry._unregistered_member` without either lookup
287
+ table growing -- is for that exact reason invisible to the
288
+ ``_value2member_map_`` check above. Such a value resolves through
289
+ ``cls(value)`` but not through ``get(value)`` when ``value`` is a
290
+ ``str``; the non-``str`` path below has no such gap, since it always
291
+ calls ``cls(key)`` and so always reaches ``_missing_``. Closing that
292
+ gap here would mean calling ``cls(key)`` for a ``str`` value too,
293
+ which reopens the exact minting hazard the paragraph above exists to
294
+ avoid -- so the asymmetry is deliberate, not an oversight.
295
+
296
+ The non-``str`` path calls :meth:`_validate_value` immediately before
297
+ ``cls(key)``, which is the only point at which this method can reach a
298
+ subclass's ``_missing_``, so a subclass that declares a range gets it
299
+ checked before the constructor rather than after. The base hook accepts
300
+ everything, so this changes nothing for a subclass that does not override
301
+ it. A rejection raised as
302
+ :exc:`~pcapkit.utilities.exceptions.EnumValueError` -- or any other
303
+ :exc:`ValueError` subclass -- is caught by the same ``except`` that
304
+ catches an ordinary failed construction, and so falls back to ``default``
305
+ on the same terms; the ``str`` path does not call the hook, for the reason
306
+ given on :meth:`_validate_value` itself.
307
+
308
+ The hook and ``cls(key)`` run inside a
309
+ :class:`~pcapkit.utilities.exceptions.CaughtByCaller` block for
310
+ :exc:`ValueError`, because every :exc:`ValueError` they raise is this
311
+ method's own lookup miss: caught here, then answered with ``default`` or
312
+ raised to the caller as the miss. A loud
313
+ :exc:`~pcapkit.utilities.exceptions.EnumValueError` an override
314
+ constructs there is therefore quiet, though the override never passes
315
+ ``quiet=True`` -- the generated overrides cannot know which caller they
316
+ serve. An error of any other class is not a lookup miss and escapes
317
+ this method as it was raised, so it stays loud.
318
+
319
+ Both failure paths raise from :mod:`pcapkit.utilities.exceptions`
320
+ rather than a builtin, per the ruling recorded on GitHub issue
321
+ :issue:`923`: in-library code raises from :mod:`pcapkit.utilities.exceptions`
322
+ rather than a builtin, and whether ``ValueError`` or ``KeyError`` applies
323
+ follows what stdlib's ``Enum`` raises in the same circumstance: a name
324
+ miss is :exc:`KeyError`-derived and a value miss :exc:`ValueError`-derived,
325
+ matching ``E['nosuch']`` and ``E(999)`` on a stdlib :class:`~enum.Enum`,
326
+ so every ``except KeyError`` and ``except ValueError`` around a call to
327
+ this method catches.
328
+
329
+ These details are worth stating, since the exception type alone does
330
+ not show them:
331
+
332
+ * **Every miss is quiet**, by name or by value, whether answered with
333
+ ``default`` or raised: nothing is logged and no exception hook is
334
+ installed. A raised miss still reaches the caller as an ordinary
335
+ exception; left uncaught, it is printed by whichever hook is installed
336
+ -- the interpreter's own in development mode, ``tbtrim``'s otherwise,
337
+ unless a loud error has installed :mod:`pcapkit`'s. The name miss is
338
+ :exc:`~pcapkit.utilities.exceptions.EnumKeyError` with
339
+ ``quiet=True``, because it is in-library control flow -- in the
340
+ ``get`` override of :class:`~pcapkit.const.http.method.Method` it is
341
+ part of a *successful* call, since that override catches it in order
342
+ to build an unregistered member. The value miss is quiet through the block
343
+ described above, as ruled on :issue:`1845` on the ground that this
344
+ method is mostly called from protocol parsing: a value it cannot
345
+ resolve is input for the caller to handle, not a fault to report. A
346
+ loud miss would put a :data:`logging.CRITICAL` record on every such
347
+ call -- the GitHub issue :issue:`362` defect
348
+ :class:`~pcapkit.utilities.exceptions.BaseError` documents ``quiet``
349
+ for -- and, outside development mode, install :mod:`pcapkit`'s
350
+ exception hooks. :meth:`EnumRegistry.register` refusing the same
351
+ value stays loud.
352
+ * **An in-library rejection propagates unchanged.** A ``ValueError``
353
+ that is already a :exc:`~pcapkit.utilities.exceptions.BaseError` --
354
+ typically :exc:`~pcapkit.utilities.exceptions.EnumValueError` from a
355
+ subclass's :meth:`_validate_value` -- is re-raised as it stands rather
356
+ than wrapped, so the subclass's own message survives and no second
357
+ error is constructed. Only |aenum|_'s and :mod:`enum`'s own "no
358
+ member carries this value" is converted, into a quiet
359
+ :exc:`~pcapkit.utilities.exceptions.EnumValueError`. This is the same
360
+ discrimination :meth:`EnumField.post_process
361
+ <pcapkit.corekit.fields.numbers.EnumField.post_process>` already
362
+ makes for the same reason.
363
+
364
+ Args:
365
+ key: Name or value to look up.
366
+ default: An already-registered value to fall back to when
367
+ ``key`` does not resolve. Resolved through a plain
368
+ ``_value2member_map_`` lookup, never through
369
+ ``cls(default)``, so it cannot mint -- see :issue:`864`.
370
+ :data:`~pcapkit.corekit.sentinels.NO_DEFAULT` stands for *no
371
+ default*; that and a ``default`` naming no registered member
372
+ both fall through to the same lookup error ``key`` itself would
373
+ have raised.
374
+
375
+ Returns:
376
+ The canonical member for ``key``, or for ``default``.
377
+
378
+ Raises:
379
+ EnumValueError: If a value does not resolve and there is no usable
380
+ default. Also what a subclass's :meth:`_validate_value`
381
+ rejection reaches the caller as, since that hook is documented
382
+ to raise this very class and it is passed through rather than
383
+ re-wrapped. A :exc:`ValueError`, so an
384
+ ``except ValueError`` caller is unaffected. Quiet.
385
+ EnumKeyError: If a name does not resolve and there is no usable
386
+ default. A :exc:`KeyError`, so an ``except KeyError`` caller is
387
+ unaffected. Quiet.
388
+
389
+ .. versionchanged:: 1.5.0
390
+
391
+ A value miss is quiet, whether ``default`` answers it or it is
392
+ raised: it logs nothing and installs no exception hook, while
393
+ :meth:`EnumRegistry.register` still reports the same range
394
+ rejection loudly (:issue:`1845`).
395
+
396
+ """
397
+ if isinstance(key, str):
398
+ try:
399
+ return cls._member_map_[key]
400
+ except KeyError:
401
+ if key in cls._value2member_map_:
402
+ return cls._value2member_map_[key]
403
+ if default is NO_DEFAULT or default not in cls._value2member_map_:
404
+ raise EnumKeyError(f'{key!r} is not a valid {cls.__name__}',
405
+ quiet=True) from None
406
+ return cls._value2member_map_[default]
407
+ try:
408
+ # NOTE: Every ValueError raised here is this method's own lookup miss, so a loud
409
+ # one is quiet here, whoever constructed it (#1845).
410
+ with CaughtByCaller(ValueError):
411
+ cls._validate_value(key)
412
+ return cls(key) # type: ignore[call-arg]
413
+ except ValueError as error:
414
+ if default is NO_DEFAULT or default not in cls._value2member_map_:
415
+ if isinstance(error, BaseError):
416
+ raise
417
+ raise EnumValueError(str(error), quiet=True) from error
418
+ return cls._value2member_map_[default]
419
+
420
+ @classmethod
421
+ def get_all(cls, key: 'Any') -> 'tuple[Self, ...]':
422
+ """Every member matching ``key``, canonical first.
423
+
424
+ For a registry that maps one key to one member -- which is every
425
+ registry inheriting this base unmodified -- that tuple holds exactly one
426
+ entry, since an alias registered by :meth:`~EnumRegistry.register_alias` is a second
427
+ *name* for the canonical member rather than a second member. The method
428
+ still exists here, because ``get``, ``get_all``, ``register`` and
429
+ ``register_alias`` are all to exist on every const registry (GitHub
430
+ issue :issue:`842`), and it is where a registry with genuinely
431
+ several matches puts them: :class:`~pcapkit.const.reg.apptype.apptype.AppType` overrides it
432
+ to return every service IANA assigns to a port.
433
+
434
+ Args:
435
+ key: Name or value to look up.
436
+
437
+ Returns:
438
+ The canonical member, followed by any further distinct member
439
+ carrying the same value.
440
+
441
+ Raises:
442
+ EnumValueError: As :meth:`get` with no default, for a value.
443
+ EnumKeyError: As :meth:`get` with no default, for a name.
444
+
445
+ """
446
+ canonical = cls.get(key)
447
+ return (canonical, *(
448
+ member for member in cls._member_map_.values() if member is not canonical
449
+ and member.value == canonical.value # type: ignore[attr-defined]
450
+ ))
451
+
452
+
453
+ class EnumRegistry(EnumLookup):
454
+ """Registry protocol shared by every open constant enumeration under
455
+ :mod:`pcapkit.const`.
456
+
457
+ :class:`EnumLookup` above carries the read half -- :meth:`~EnumLookup.get`,
458
+ :meth:`~EnumLookup.get_all` and :meth:`~EnumLookup._validate_value`, all
459
+ inherited here unchanged. What this tier adds is the half that makes a
460
+ registry *open*: :meth:`register`, :meth:`register_alias`,
461
+ :meth:`register_aliases`, :meth:`_extend`, :meth:`_unregistered_member` and
462
+ :meth:`_make_reducible`.
463
+
464
+ An enumeration inherits from *here* when it may grow at runtime, and from
465
+ :class:`EnumLookup` directly when it may not. The owner's ruling on GitHub
466
+ issue :issue:`877` is what draws that line: an enumeration is immutable
467
+ unless RFC or IANA says otherwise.
468
+
469
+ Mixed in ahead of the enum base -- ``class
470
+ Foo(EnumRegistry, IntFlag)`` -- and gaining :class:`EnumLookup` as a parent
471
+ does not disturb that: both tiers are plain classes, so ``_member_type_``
472
+ still resolves past them to the enumeration base.
473
+
474
+ """
475
+
476
+ @classmethod
477
+ def register(cls, value: 'Any', name: 'str') -> 'Self':
478
+ """Mint a new member on this registry at runtime, under ``name``.
479
+
480
+ The caller-named path, and the only one that grows the registry:
481
+ it mints a new member on the class at runtime under the ``name`` the
482
+ caller specifies, so nothing has to be guessed (GitHub issue :issue:`842`).
483
+ Contrast :meth:`~EnumLookup.get` and ``_missing_``, which resolve without naming anything.
484
+
485
+ Refuses a ``value`` that already has a member. Without this guard,
486
+ ``aenum.extend_enum`` does not mint anything for an already-taken
487
+ value -- |aenum|_ treats that as a request to *alias* the existing
488
+ member under the caller's ``name`` instead, silently: the call returns
489
+ the *existing* member, ``name`` becomes reachable in ``__members__``
490
+ pointing at it, and ``_member_names_`` does not grow. That is
491
+ :meth:`register_alias`'s own effect, reached through the wrong method
492
+ and with nothing raised to say so -- exactly the "guess blindly" this
493
+ method exists to rule out. Membership is tested against
494
+ ``_value2member_map_`` rather than by calling ``cls(value)``, for the
495
+ same reason :meth:`register_alias` tests it that way: a
496
+ declared-but-unassigned value resolves through ``_missing_`` to an
497
+ :meth:`_unregistered_member` absent from that table, so a successful
498
+ call proves nothing about whether a member already exists.
499
+
500
+ Routes through :meth:`~EnumLookup._validate_value` before minting, so a
501
+ subclass that declares a range gets it enforced on the caller-named path
502
+ too and not only on the lookup one. The duplicate check runs *first*: a
503
+ ``value`` that already has a member is legal by construction, so the
504
+ actionable "use ``register_alias()`` instead" message is the better answer
505
+ for it than a range complaint would be, and validation is left to guard
506
+ only the genuinely new value that is about to be minted.
507
+
508
+ That rejection is always loud. :meth:`~EnumLookup.get` quiets the same
509
+ hook, because there the rejection is a lookup miss for the caller to
510
+ handle; here it refuses a mint the caller explicitly asked for, which
511
+ is a fault to report. So this calls the hook in a
512
+ :class:`~pcapkit.utilities.exceptions.CaughtByCaller` block declaring
513
+ that nothing is caught -- loud even if ``register`` is reached from
514
+ inside a ``get`` (:issue:`1845`).
515
+
516
+ Args:
517
+ value: Value of the new member.
518
+ name: Name of the new member. Required rather than derived, which
519
+ is the whole point -- a generated name is a guess.
520
+
521
+ Returns:
522
+ The newly registered member.
523
+
524
+ Raises:
525
+ ValueError: If ``value`` already has a member -- use
526
+ :meth:`register_alias` to add a further name for it instead.
527
+ EnumValueError: If a subclass's
528
+ :meth:`~EnumLookup._validate_value` rejects ``value``. The base
529
+ implementation of that hook accepts everything, so this cannot
530
+ arise on a registry that does not override it.
531
+ ValueError: If ``name`` is already taken. |aenum|_ reports that
532
+ as :exc:`TypeError`; it is translated so that the ways one call
533
+ can fail are one exception type.
534
+
535
+ """
536
+ if value in cls._value2member_map_:
537
+ existing = cls._value2member_map_[value]
538
+ raise ValueError(f'{value!r} is already registered on {cls.__name__} as '
539
+ f'{existing.name!r}; use {cls.__name__}.register_alias() '
540
+ f'to add a further name for it')
541
+ # NOTE: GitHub issue #1845. Declares that nothing is caught, so the
542
+ # rejection stays loud even inside a ``get`` block that would quiet it.
543
+ with CaughtByCaller():
544
+ cls._validate_value(value)
545
+ return cls._extend(value, name)
546
+
547
+ @classmethod
548
+ def _extend(cls, value: 'Any', name: 'str') -> 'Self':
549
+ """The raw ``aenum.extend_enum`` call, shared by :meth:`register`
550
+ and :meth:`register_alias`.
551
+
552
+ Neither public method calls the other: :meth:`register` refuses an
553
+ already-registered ``value`` before it would ever reach here, and
554
+ :meth:`register_alias` depends on the opposite of that -- it verifies
555
+ ``value`` *is* already registered and then relies on exactly the
556
+ mint-or-alias behaviour this wraps to add ``name`` as a further name
557
+ for the existing member rather than a new one. Routing both through
558
+ this shared, ungated call is what keeps that behaviour available to
559
+ :meth:`register_alias` while :meth:`register` still rejects it.
560
+
561
+ Args:
562
+ value: Value of the member, new or existing.
563
+ name: Name to add.
564
+
565
+ Returns:
566
+ The member now reachable under ``name``, new or existing.
567
+
568
+ Raises:
569
+ ValueError: If ``name`` is already taken. |aenum|_ reports that
570
+ as :exc:`TypeError`; it is translated so that the ways one call
571
+ can fail are one exception type.
572
+
573
+ """
574
+ try:
575
+ return extend_enum(cls, name, value)
576
+ except TypeError as error:
577
+ raise ValueError(str(error)) from error
578
+
579
+ @classmethod
580
+ def register_alias(cls, value: 'Any', name: 'str') -> 'Self':
581
+ """Add ``name`` as a further name for the member already at ``value``.
582
+
583
+ Per GitHub issue :issue:`842`, an alias adds a further name to a given
584
+ member's mapping -- so it needs an existing member to attach to, and this
585
+ refuses a value no member carries rather than falling through to
586
+ :meth:`register`. :issue:`842` settled on an alias always attaching to an
587
+ existing member, leaving open whether :class:`~pcapkit.const.reg.apptype.apptype.AppType` or a concrete
588
+ enumeration might need to alias a value no member carries. :class:`~pcapkit.const.reg.apptype.apptype.AppType`'s
589
+ override does not: it requires the port to already carry a member of that
590
+ very registry. What an alias means also differs away from
591
+ :class:`~pcapkit.const.reg.apptype.apptype.AppType`: on every other registry it is a custom
592
+ name the caller opts into, not one recorded by the IANA registrars. Minting under the name
593
+ of an aliasing call would manufacture exactly the unrecorded member :issue:`775` removes.
594
+
595
+ Membership is tested against ``_value2member_map_`` rather than by
596
+ calling ``cls(value)``: a declared-but-unassigned value resolves through
597
+ ``_missing_`` to an :meth:`_unregistered_member` that is deliberately
598
+ absent from that table, so a successful call proves nothing about
599
+ whether a member exists.
600
+
601
+ On this base, an alias adds a *name*, not a member: ``__members__`` grows
602
+ by one while ``_member_names_``, iteration and ``_value2member_map_`` are
603
+ untouched. Calls :meth:`_extend` directly rather than :meth:`register`, which
604
+ would refuse this call outright -- :meth:`register` and
605
+ :meth:`register_alias` test ``value``'s membership for opposite
606
+ outcomes, so neither can be the other's implementation.
607
+ :class:`~pcapkit.const.reg.apptype.apptype.AppType`'s override differs: it mints a real member through
608
+ ``aenum.extend_enum``, so its iteration grows too.
609
+
610
+ Args:
611
+ value: Value of the existing member to alias.
612
+ name: Alias to add for it.
613
+
614
+ Returns:
615
+ The existing member, now reachable under ``name`` as well.
616
+
617
+ Raises:
618
+ ValueError: If no member carries ``value``, or if ``name`` is
619
+ already taken.
620
+
621
+ """
622
+ if value not in cls._value2member_map_:
623
+ raise ValueError(f'{value!r} is not a registered {cls.__name__}; '
624
+ f'use {cls.__name__}.register() to mint one')
625
+ return cls._extend(value, name)
626
+
627
+ @classmethod
628
+ def register_aliases(cls, value: 'Any', *names: 'str') -> 'tuple[Self, ...]':
629
+ """Add several aliases for the member at ``value``, left to right.
630
+
631
+ Args:
632
+ value: Value of the existing member to alias.
633
+ *names: Aliases to add for it.
634
+
635
+ Returns:
636
+ One entry per name in ``names``, each the aliased member.
637
+
638
+ Raises:
639
+ ValueError: As :meth:`register_alias`. Names before the failing one
640
+ stay registered -- ``aenum.extend_enum`` has no transaction
641
+ to roll back, and undoing it by hand would mean reaching further
642
+ into enumeration internals than anything else here does.
643
+
644
+ """
645
+ return tuple(cls.register_alias(value, name) for name in names)
646
+
647
+ @classmethod
648
+ def _unregistered_member(cls, value: 'Any', name: 'str') -> 'Self':
649
+ """Build a member absent from this registry's own lookup tables.
650
+
651
+ Used by a registry's ``_missing_`` for a declared-but-unassigned value
652
+ it resolves without anyone asking for a name, so that such a lookup does
653
+ not grow the registry -- contrast :meth:`register`, the explicit path
654
+ that does.
655
+
656
+ The member is constructed through ``cls._member_type_``, which
657
+ |aenum|_ sets from the enumeration base, so this serves ``int``- and
658
+ ``str``-valued registries alike without either having to say which it
659
+ is.
660
+
661
+ Args:
662
+ value: The member's value.
663
+ name: The member's name.
664
+
665
+ Returns:
666
+ The unregistered member.
667
+
668
+ """
669
+ obj = cls._member_type_.__new__(cls, value)
670
+ obj._name_ = name # pylint: disable=protected-access
671
+ obj._value_ = value # pylint: disable=protected-access
672
+ return obj
673
+
674
+ @classmethod
675
+ def _make_reducible(cls, obj: 'Any', *args: 'Any') -> 'Any':
676
+ """Make an unregistered member survive :mod:`pickle` and :mod:`copy`.
677
+
678
+ ``Enum.__reduce_ex__`` reduces a member to ``(cls, (value,))``, i.e. to
679
+ a *value*-keyed lookup -- the one table an unregistered member is
680
+ deliberately absent from. So a member :meth:`_unregistered_member`
681
+ built pickles happily and then raises :exc:`ValueError` on read-back,
682
+ where the failure is a long way from its cause.
683
+
684
+ This replaces that reduction with one through
685
+ :func:`_rebuild_unregistered_member`, which re-enters
686
+ ``cls._unregistered_member(*args)``. Rebuilding therefore takes exactly
687
+ the path that built the original and never ``cls.__new__``, so an
688
+ unpickled member is unregistered just as the original was and no
689
+ lookup table grows. The rebuilt member is itself reducible, since the
690
+ method it comes back through installs this again.
691
+
692
+ The override goes on the *instance* rather than on the type, through
693
+ :func:`~pcapkit.utilities.pickle.reduce_to`, which :mod:`pickle` and
694
+ :mod:`copy` both honour, and which keeps the member out of its own
695
+ reducer.
696
+
697
+ Note:
698
+ This is opt-in per registry rather than done by
699
+ :meth:`_unregistered_member` itself, because the arguments to
700
+ rebuild *from* are the overriding method's own, not this base
701
+ method's. :class:`~pcapkit.const.reg.apptype.apptype.AppType`,
702
+ for one, hands its base the crafted ``'svc [port - proto]'``
703
+ string while its own entry point takes ``(port, name, proto)``;
704
+ reducing to the former would rebuild a member whose value had been
705
+ formatted twice. A registry whose ``_missing_`` calls
706
+ :meth:`_unregistered_member` directly is unaffected and keeps
707
+ reducing the way ``Enum`` does.
708
+
709
+ Args:
710
+ obj: The unregistered member to install the reducer on.
711
+ *args: The arguments ``cls._unregistered_member`` should be called
712
+ with to rebuild an equivalent member.
713
+
714
+ Returns:
715
+ ``obj``, for use as a ``return`` expression.
716
+
717
+ """
718
+ return reduce_to(obj, _rebuild_unregistered_member, cls, args)
719
+
720
+
721
+ def _rebuild_unregistered_member(namespace: 'Type[EnumRegistry]',
722
+ args: 'tuple[Any, ...]') -> 'Any':
723
+ """Rebuild the member :meth:`EnumRegistry._make_reducible` reduced.
724
+
725
+ This is what :mod:`pickle` and :mod:`copy` reconstruct through, in place of
726
+ the value lookup ``Enum.__reduce_ex__`` would have reduced the member to.
727
+ It is a module-level function rather than a method so that every
728
+ :mod:`pickle` protocol can name it: protocols below 4 cannot reference a
729
+ callable nested inside a class.
730
+
731
+ Args:
732
+ namespace: The registry class to rebuild the member as an instance of.
733
+ args: The arguments to ``namespace._unregistered_member``.
734
+
735
+ Returns:
736
+ A member equal to the original and, like it, absent from every one of
737
+ ``namespace``'s lookup tables.
738
+
739
+ """
740
+ return namespace._unregistered_member(*args) # pylint: disable=protected-access
741
+
742
+