Skip to content

fix(ipx)!: keep the octets past the IPX Length field as captured (#1433) - #1435

Merged
JarryShaw merged 1 commit into
mainfrom
fix/1433-ipx-trailer-kept
Oct 8, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
fix/1433-ipx-trailer-kept

Conversation

@JarryShaw

Copy link
Copy Markdown
Owner

Closes #1433

This is the IPX counterpart of #1431 and has the same shape, without depending on it. The schema gains a length-less trailer PayloadField after the payload. read() keeps it as info.trailer only when it is non-empty. make(trailer=) writes it after the packet and leaves it out of the Packet Length, and _make_data round-trips it. Breaking: info gains a key on padded frames.

case before after
Ethernet + IPX(30), zero / junk padding to 60 60 → 44 60 → 60, trailer 16 B
bare IPX(34) + 5 extra 39 → 34 39 → 39
exact / truncated (Length 40, 34 captured) 34 → 34 unchanged, no trailer

Tests: the new tests/protocols/internet/test_ipx_trailer_kept_unit.py passes 4 tests and 4 subtests. Without the fix, 2 tests and 2 subtests fail. The other IPX modules, every tests/protocols/link module, tests/project (404 passed, 1 skipped) and the protocols/internet leg (580 tests, OK) all pass. Per-frame info for every examples/captures/ file is identical before and after.

Ethernet hands IPX the whole rest of its frame, but IPX reads only its
Packet Length, so the octets past it (most often minimum-frame padding)
were in no info and from_data dropped them: a padded 60-octet frame
rebuilt as 44.

- schema: add a length-less trailer PayloadField after the payload
- read(): record it as info.trailer, only when non-empty
- make(trailer=): write it after the packet, outside the Packet Length
- _make_data(): round-trip it

BREAKING: IPX info gains a trailer key on padded frames.
@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 8, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Verdict: GOOD TO GO at 3075bd3d2 (Sonnet cross-review; the author ran on Opus).

  • Re-derived by me: a well-formed 30-octet IPX header in a 60-octet Ethernet frame rebuilds at 44 octets on main (a8cc02594) and stays exact at 60 here.
  • Reviewer:
    • Junk padding: also 60 → 60, with a 16 B trailer.
    • Bare IPX with Length 34 plus 5 extra octets: 39 → 34 on main, exact here.
    • Exact-length and truncated packets (Length 40, 34 captured) have no trailer key and no over-read.
    • Length below the header (20, 0, 29): unchanged from main, and exact.
  • Payload to the next layer is exactly Length − 30 (Raw b'abcd' for Length 34).
  • make(trailer=): the trailer is written after the packet and Length excludes it. Make → parse round-trips.
  • Same shape as fix(ipv4,ipv6)!: keep the octets past Total Length or Payload Length as captured (#1209) #1431: a PayloadField(default=b'') after the payload, if schema.trailer: in read, and data.get('trailer', b'') in _make_data. None handling is the same in both, and so is the bytearray rejection, which is shared and pre-existing. The two PRs touch disjoint files.
  • Tests:
    • With the 3 IPX files reverted, 4 tests fail.
    • test_ipx_unit, test_ipx_ah_roundtrip_unit, tests/protocols/link (70), test_docstring_contract and tests/project (404) all pass.
    • Per-frame info is identical across the 22 sample captures. None of them carries IPX.
  • ! is justified, on the same grounds as fix(ipv4,ipv6)!: keep the octets past Total Length or Payload Length as captured (#1209) #1431.

@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 8, 2026
@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Coverage: 89.45% (unit tier, Python 3.14, 3075bd3d2, Unit Tests run success)

Package Statements Missed Branches Partial Cover
pcapkit (top level) 104 4 20 4 93.55%
pcapkit/const 18791 968 2352 869 90.90%
pcapkit/corekit 2038 89 634 25 94.76%
pcapkit/dumpkit 234 2 84 2 98.74%
pcapkit/foundation 2637 98 928 48 94.78%
pcapkit/interface 112 7 40 5 92.11%
pcapkit/protocols 16618 221 4476 185 98.04%
pcapkit/toolkit 539 74 168 3 84.58%
pcapkit/utilities 429 4 122 4 98.55%
pcapkit/vendor 4409 2342 1006 157 43.25%

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

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

Development

Successfully merging this pull request may close these issues.

fix(ipx): octets past the IPX Length field are dropped on rebuild

1 participant