Skip to content

refactor(protocols)!: range-check the transport makers and adopt the shared helpers (#2614) - #2670

Merged
JarryShaw merged 1 commit into
mainfrom
refactor/2614-transport-helpers
Nov 2, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
refactor/2614-transport-helpers

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

The transport group of #2614: TCP, UDP, DCCP and SCTP take the shared value helpers on Protocol.

  • Breaking: the released makers stop wrapping. Under the owner's refactor(protocols): move shared value pack/unpack helpers into the Protocol utilities #2614 answer 2, an integer field given a value it cannot hold raises ProtocolError naming the field. Measured on main, TCP(window=70000) packed 0x1170 and seq_no=-1 packed 0xffffffff. A fixed-size octet field of the wrong size raises too, where it used to be padded or cut.
  • TCP User Timeout keeps its 15-bit-minutes limit, and also refuses a negative, bool or non-numeric timeout by name.
  • The Quick-Start TTL Diff wraps on purpose, since RFC 4782 defines it modulo 256. A test pins this.
  • Padding goes through pad_length, and DCCP's NDP Count is sized with _uint_size.

Parsed output is byte-identical to main across every generated capture, and every TCP, UDP, SCTP and DCCP layer rebuilds exactly. A Sonnet cross-review ran over two rounds: the first found the User Timeout leak, and the second asked for the TTL Diff pin. Both are fixed in this head.

Part of #2614; the internet and PCAP-NG/ARP groups follow in their own PRs.

…shared helpers (#2614)

BREAKING CHANGE: the released TCP, UDP and SCTP makers stop wrapping. A value
an integer field cannot hold raises ProtocolError naming the field, where it
was written as its low bits (TCP(window=70000) packed 0x1170, seq_no=-1 packed
0xffffffff), and a fixed-size octet field of the wrong size raises where it
was padded or cut.

- TCP, UDP, DCCP and SCTP make() and their option, chunk, parameter and cause
  makers check each integer field with _make_uint, bar the two below, and each
  fixed-size octet field with _make_octets; a UDP Length and an SCTP chunk,
  parameter or cause length past 16 bits, given or computed, raises.
- TCP _make_mode_timeout keeps its 15-bit-minutes limit and also refuses, by
  name, a timeout that is negative, a bool, or neither an int nor a timedelta,
  where a bare ValueError or AttributeError came out or True packed 1 second.
- The Quick-Start TTL Diff keeps wrapping: RFC 4782 defines it modulo 256.
- TCP _make_tcp_options, DCCP _make_dccp_options and SCTP _padding_width pad
  with pad_length; DCCP _make_opt_ndp_count sizes its count with _uint_size.
- New test_transport_maker_range_2614_unit; the MPTCP unknown-subtype case in
  test_tcp_udp_unit gives a first data octet that fits its four bits.
@JarryShaw JarryShaw added this to the PyPCAPKit v1.6 milestone Nov 2, 2026
@JarryShaw JarryShaw added breaking Breaks public-facing behaviour or API (apply alongside the type label) 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 f1e93bb3c, after two Sonnet rounds. Every changed maker refuses what its field cannot carry, by name. The TTL Diff exception is deliberate and pinned. Parsed output matches main, and every transport layer rebuilds byte-exact.

@JarryShaw JarryShaw moved this to In review in PyPCAPKit Nov 2, 2026
@JarryShaw
JarryShaw merged commit 2237762 into main Nov 2, 2026
62 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in PyPCAPKit Nov 2, 2026
@JarryShaw
JarryShaw deleted the refactor/2614-transport-helpers branch November 2, 2026 18:26
@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

breaking Breaks public-facing behaviour or API (apply alongside the type label) 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.

1 participant