Skip to content

fix(link): keep a captured FRAD pad octet through a whole-frame rebuild (#2716) - #2721

Merged
JarryShaw merged 1 commit into
mainfrom
fix/2716-frad-pad-rebuild
Nov 3, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
fix/2716-frad-pad-rebuild

Conversation

@JarryShaw

Copy link
Copy Markdown
Owner

What is the purpose of your pull request?

  • fix — corrects a defect

A whole FRAD frame lost or gained a pad octet when rebuilt. 0c21 03 00 cc + IPv4 rebuilt without its pad, and 0c21 03 80 000000 0806 + ARP rebuilt with one. RFC 2427 §3 allows the single zero pad "when required", before any NLPID, but the data model did not record whether a pad was captured.

  • Data model: a new pad: bool field. read() sets it when the first NLPID octet is zero.
  • make(pad=None): by default the pad goes before SNAP (0x80) and before an NLPID of 0, so a direct build is unchanged. A differential over six NLPIDs gives identical octets. True and False override the default, and pad=False with an NLPID of 0 raises ProtocolError. This follows the presence-flag pattern of GRE checksum_present and L2TPv2 length_flag.
  • Docs: prose that called the pad SNAP-only now matches RFC 2427 §3 and §4.1.

Both frames now rebuild exactly through from_data(info) and from_data(info.to_dict()), whole and at every cut, and behind LinuxSLL1 and LinuxSLL2. Nothing is logged. The new tests fail on main. FRAD has not shipped, so the new required field breaks no release.

Closes #2716

…ld (#2716)

RFC 2427 section 3 allows the one zero pad octet ahead of any NLPID, and
FRAD reads one wherever it is, but the data model did not record it, so
make() wrote the pad ahead of a SNAP header alone. A pad ahead of a direct
NLPID (0c21 03 00 cc) was lost on a rebuild, and one was invented ahead of
a SNAP header captured without it (0c21 03 80 ...).

- The FRAD data model records pad, and _make_data passes it on.
- make() takes pad. When it is None, the pad goes ahead of a SNAP header
  alone, as RFC 2427 section 4.1 writes it, and ahead of an NLPID of 0, which
  reads as the pad, so a direct build is unchanged. pad=False with an NLPID
  of 0 raises ProtocolError.
- The FRAD prose stops calling the pad SNAP's alone.

test_frad_pad_rebuild_2716_unit fails without the pcapkit/ change, but for
the control that a direct build is unchanged. Shipped captures parse
identically. The link, internet, project and root protocols modules, both
schema round trips, and the #2710 and short-read sweeps pass.

Closes #2716
@JarryShaw JarryShaw added this to the PyPCAPKit v1.6 milestone Nov 3, 2026
@JarryShaw JarryShaw added bug Issues reporting a defect (set by the bug report template; a default, not an assessment) review: good-to-go Cross-review at the current head says ready; CI state is separate labels Nov 3, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

GOOD TO GO at e864fd801, from a Sonnet review of 2f483b6f4. The rebase onto main keeps the same patch-id.

  • A differential over six NLPIDs shows direct builds unchanged. Both frames rebuild exactly through info and to_dict, whole and at every cut, and behind LinuxSLL1 and LinuxSLL2. Nothing is logged.
  • The RFC 2427 §3 and §4.1 wording checks out against the fetched text. The test fails 143 cases on the base, and its control passes there.
  • Optional nit: pad is not type-checked, so 2 reads as true. GRE's checksum_present behaves the same way.

@JarryShaw
JarryShaw merged commit 982b542 into main Nov 3, 2026
27 checks passed
@JarryShaw
JarryShaw deleted the fix/2716-frad-pad-rebuild branch November 3, 2026 03:03
@github-project-automation github-project-automation Bot moved this to Done in PyPCAPKit Nov 3, 2026
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Nov 3, 2026
JarryShaw added a commit that referenced this pull request Nov 3, 2026
…s.pickle, FRAD's pad and the TCP and HIP maker fixes into 1.6.0 (#2449)

- Breaking: a fixed-size octet field given any other width raises, where
  1.5.x padded or cut it, and IPv4's Timestamp option refuses a slot count
  past what it holds, where 1.5.x cut it (#2691); folded into the IPv4 to HIP
  makers' range-check entry, with the ZigBee keys into the PCAP-NG entry. Old
  values measured against v1.5.1.
- Added: pcapkit.utilities.pickle, whose ReduceAsProtocol2 lets Info, Schema
  and the reassembly engines pickle under protocols 0 and 1 on GraalPy, and
  numbers._reduce_unregistered_member's removal (#2722).
- Fixed: TCP's raw-octet options, HIP's default version, HIP's ENCRYPTED IV
  and its cipher on parse (#2724).
- Folded into unreleased entries: FRAD's pad field and make(pad=) (#2721).
- No entry for the docstring-only 596dcfa, the test-only 149cced, or
  #2724's MH annotation.
- 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

bug Issues reporting a defect (set by the bug report template; a default, not an assessment)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

fix(link): a FRAD pad octet is lost or invented when a whole frame is rebuilt

1 participant