Skip to content

refactor(protocols): index each protocol by its LinkType, EtherType, TransType or AppType value (#2627) - #2652

Merged
JarryShaw merged 1 commit into
mainfrom
refactor/2627-index-standard-values
Nov 2, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
refactor/2627-index-standard-values

Conversation

@JarryShaw

Copy link
Copy Markdown
Owner

What is the purpose of your pull request?

  • refactor — changes neither behaviour nor performance

Description of your pull request and other information

A protocol's __index__ returns its LinkType, EtherType, TransType or AppType value where one exists, as the owner ruled in session. registry-protocol.rst records the rule.

Dispatch maps and every capture are identical to main. Sonnet cross-reviews confirmed the code at each round. The last one asked for one docs sentence, which this head fixes.

Closes #2627

@JarryShaw JarryShaw added this to the PyPCAPKit v1.6 milestone Nov 2, 2026
@JarryShaw JarryShaw added refactor Restructuring for its own sake — neither a fix nor a new capability (refactor: prefix) review: good-to-go Cross-review at the current head says ready; CI state is separate labels Nov 2, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

GOOD TO GO at 67bca4635. A Sonnet cross-review checked the code: a census of every Protocol subclass against main and v1.5.1, a registry lookup of each returned value, lazy imports in fresh interpreters, and identical dispatch maps and captures. The one docs sentence it asked for (IPv4/IPv6 are also LinkType-keyed) is fixed in this head.

@JarryShaw

Copy link
Copy Markdown
Owner Author

resolve conflicts

@JarryShaw

Copy link
Copy Markdown
Owner Author

The owner asked for the conflicts to be resolved. They are with #2651's rewrite of http.py and http.rst. The worker is rebasing onto main (8f6aee6a8) now, and a note follows when it is pushed.

…TransType or AppType value (#2627)

- Radiotap and FRAD return LinkType 127 and 107, and GRE TransType 47,
  where each returned its ARPHRD type. Netlink keeps ARPHRD_NETLINK, as
  LINKTYPE_NETLINK names the SLL-framed form.
- L2TPv2, FTP, FTP_DATA, HTTP (inherited by HTTPv1 and HTTPv2), NGAP, TLS
  (inherited by SSLv3) and DTLS return their IANA port as an int: an
  AppType member is a str, which int() and operator.index() reject from
  __index__. TLS and DTLS return 443 and 5684, the ports TCP and UDP bind
  them at. The TCP and UDP registries are imported in __index__ to stay
  lazy (#1538).
- Every dispatch table is unchanged: LinuxSLL keys its entries by literal
  ARPHRD members, and FRELAY and IP protocol 47 stay unbound, recorded in
  the reachability audit's UNBOUND table, checked both ways (#2649).
- A new test pins each class's value from its registry number, and int()
  and operator.index() on an instance of each AppType-valued class; tests
  that pinned the ARPHRD values or the raises are updated.
- registry-protocol.rst records the rule, the port form, the Netlink
  exception, and which classes raise and why; pep.rst, l2tp.rst and the
  L2TP docstrings drop the claim that a port is no index.
@JarryShaw
JarryShaw force-pushed the refactor/2627-index-standard-values branch from 67bca46 to e56b57c Compare November 2, 2026 16:19
@JarryShaw

Copy link
Copy Markdown
Owner Author

Conflicts resolved, rebased onto main (8f6aee6a8): 67bca4635 → e56b57c92.

The patch-id outside the two resolved files is identical (c03d95d42348). Dispatch maps and captures are identical to main. The verdict stays good to go.

@JarryShaw
JarryShaw merged commit 32935fc into main Nov 2, 2026
24 checks passed
@JarryShaw
JarryShaw deleted the refactor/2627-index-standard-values branch November 2, 2026 16:24
@github-project-automation github-project-automation Bot moved this from In review to Done in PyPCAPKit Nov 2, 2026
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Nov 2, 2026
JarryShaw added a commit that referenced this pull request Nov 2, 2026
…he cut-frame fixes and GRE's bindings into 1.6.0 (#2449)

- Breaking: TCP, UDP and SCTP makers (#2670) and PCAP-NG's (#2671) raise
  on a value a field cannot hold, where 1.5.x wrote it masked; each entry
  gives the old and new values. The TTL Diff wraps as before.
- Changed: __index__ returns the LinkType, EtherType, TransType or AppType
  value, ports as ints (#2652); only Create Release waits for a deployment
  approval (#2658). The conventions entry records the index rule.
- Fixed: a cut HTTP/2 SETTINGS frame parses and rebuilds; HTTPv2.make
  takes frame_length (#2666).
- Folded into unreleased entries: FRAD at LinkType 107 and GRE at IP
  protocol 47 (#2667); cut IGMPv3 messages and num_group_records (#2662,
  #2672); Linux_ARPHRD (#2663); DCCP's range checks (#2670); a cut GRE
  frame is TRUNCATED, replacing fold-12's INVALID note, and frame_length
  in pcapkit.utilities.contextvars (#2668).
- No entry for _make_sint's private allow_unsigned, ARP's private
  PAT_MAC_ADDR, or the test- and docs-only d728873, 326a6cf,
  fc80fb1, a37edf1 and 2766707.
- CHANGELOG.md regenerated; util/changelog_md.py --check passes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Restructuring for its own sake — neither a fix nor a new capability (refactor: prefix)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

refactor(protocols): __index__ returns the protocol's LinkType, EtherType, TransType or AppType value where one exists

1 participant