Skip to content

fix(link): ARP family rebuilds InARP/DRARP, any Ethernet hlen, and a ptype/plen mismatch - #1224

Merged
JarryShaw merged 1 commit into
mainfrom
fix/arp-roundtrip-1204-1206
Oct 7, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
fix/arp-roundtrip-1204-1206

Conversation

@JarryShaw

@JarryShaw JarryShaw commented Oct 7, 2026 •

Copy link
Copy Markdown
Owner
  • Searched for similar pull requests

  • Followed the coding style — ran pylint/mypy/isort on the two source files; isort clean, and pylint/mypy report only findings on unchanged lines (not make targets)

  • make test passes, and a test case covers the change — the modules listed below only, not the full suite

  • Added a changelog entry — N/A, added centrally after the wave

  • fix — corrects a defect


Closes #1204
Closes #1205
Closes #1206

Probe (parse, then from_data). Before: InARP/DRARP AttributeError: 'Raw' object has no attribute 'htype'; hlen 8/0 ProtocolError: Invalid MAC address; v4+plen16 FieldValueError ... 6 != 4; v4+plen5 bare ValueError. After: all nine cases (ARP/RARP/InARP/DRARP) rebuild byte-exactly.

Tests:

  • New test_arp_roundtrip_unit.py gives 8 passed, 85 subtests passed.
  • With the fix reverted it failed in every test method.
  • With only the Ethernet 6-octet default reverted, it gives 12 failed.
  • test_link_unit, test_arp_proto_addr_length_unit, test_arp_pcapng_hwaddr_octets_unit, test_rarp_unit, test_link_runtime and test_option_roundtrip_unit all pass.
  • tests/project gave 389 passed, 1 skipped before this amend.
  • run_unittest_leg.py protocols --exclude protocols/internet gives 858 test(s), 0 failure(s), 0 error(s).

@JarryShaw JarryShaw added fix Pull requests that fix a defect (fix: subject prefix) breaking Breaks public-facing behaviour or API (apply alongside the type label) review: running A cross-review is in flight against the current head - no verdict yet labels Oct 7, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Cross-review verdict on b289532fb: NEEDS CHANGES (Sonnet; author Opus).

@JarryShaw JarryShaw added review: needs-changes Cross-review at the current head says changes are required; see the verdict comment and removed review: running A cross-review is in flight against the current head - no verdict yet labels Oct 7, 2026
@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Coverage: 88.91% (unit tier, Python 3.14, cce483801, Unit Tests run success)

Package Statements Missed Branches Partial Cover
pcapkit (top level) 104 4 20 4 93.55%
pcapkit/const 18757 1034 2342 845 90.24%
pcapkit/corekit 1878 91 580 22 94.34%
pcapkit/dumpkit 142 0 42 0 100.00%
pcapkit/foundation 2442 102 852 39 94.38%
pcapkit/interface 112 7 40 5 92.11%
pcapkit/protocols 15779 190 4038 165 98.18%
pcapkit/toolkit 487 65 144 1 85.42%
pcapkit/utilities 429 4 122 4 98.55%
pcapkit/vendor 4409 2359 1006 158 42.84%

Per-file detail: the coverage-html artifact of this run.

…ptype/plen mismatch

- InARP and DRARP pass schema=/data= on their class statements, so they
  use the ARP schema instead of falling back to Raw (#1204).
- PAT_MAC_ADDR accepts any number of colon/dash-separated octets, so a
  parsed Ethernet header with hlen other than 6 (including 0) rebuilds
  through its explicit hlen; make() without hlen still requires a 6-octet
  MAC for htype Ethernet (#1205).
- The protocol address is decoded as IPv4/IPv6 only when ptype and its
  length agree (4/16); otherwise it is kept as hex, and make() packs it as
  raw octets when plen disagrees with ptype (#1206).

New tests/protocols/link/test_arp_roundtrip_unit.py covers ARP, InARP,
RARP and DRARP; it fails without the fix.

Closes #1204
Closes #1205
Closes #1206
@JarryShaw
JarryShaw force-pushed the fix/arp-roundtrip-1204-1206 branch from b289532 to cce4838 Compare October 7, 2026 17:48
@JarryShaw JarryShaw added review: running A cross-review is in flight against the current head - no verdict yet and removed review: needs-changes Cross-review at the current head says changes are required; see the verdict comment labels Oct 7, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Cross-review verdict on cce48380: GOOD TO GO (Sonnet, round 2; author Opus).

@JarryShaw JarryShaw added review: good-to-go Cross-review at the current head says ready; CI state is separate and removed review: running A cross-review is in flight against the current head - no verdict yet labels Oct 7, 2026
@JarryShaw
JarryShaw merged commit 7936025 into main Oct 7, 2026
40 checks passed
@JarryShaw
JarryShaw deleted the fix/arp-roundtrip-1204-1206 branch October 7, 2026 19:04
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Oct 7, 2026
@JarryShaw JarryShaw added this to the PyPCAPKit v1.5 milestone Oct 25, 2026
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) fix Pull requests that fix a defect (fix: subject prefix)

Projects

Status: Done

1 participant