Skip to content

IPv6: decode Routing header segments and Router Alert/Jumbo Payload - #139

Merged
EONRaider merged 1 commit into
masterfrom
claude/decoder-depth-polish-8m54to
Sep 4, 2026
Merged

IPv6: decode Routing header segments and Router Alert/Jumbo Payload#139
EONRaider merged 1 commit into
masterfrom
claude/decoder-depth-polish-8m54to

Conversation

@EONRaider

Copy link
Copy Markdown
Owner

Summary

Part of #96 (the IPv6 Routing piece — item 4, explicitly called the lowest-value/skippable of the four in the issue; landing it anyway completes #96 in full). IPv6Routing.data is entirely unparsed — no segment-list extraction for RH0, RPL or Mobile IPv6. IPv6Option likewise decodes no values (Router Alert, Jumbo Payload stay raw).

What's included

  • IPv6Routing.segments — a new property. RH0 (routing_type 0, deprecated by RFC 5095 but still seen — RFC 2460 §4.4) and Mobile IPv6 (routing_type 2, RFC 6275 §6.4) both store a 4-byte reserved field followed by one IPv6 address per segment; decodes to tuple[ipaddress.IPv6Address, ...].
  • RPL Source Routing (routing_type 3) is deliberately not decoded. RFC 6554 §3 elides a shared prefix from each intermediate address, relative to the enclosing packet's destination address — context a single extension header does not carry. This is the same class of problem DNS RDATA compression posed earlier in this tier, except here there's no message-wide buffer to fall back on (IPv6Routing only ever sees its own bytes, unlike DNSResourceRecord.rdata_value, which could reach back into DNS.sections). Attempting a partial or wrong decode would be worse than leaving it raw — data stays the only way to read an RPL header, unchanged from before this PR.
  • IPv6Option.value — decodes Router Alert (5, RFC 2711 §2.1) and Jumbo Payload (194, RFC 2675 §2) into typed ints, mirroring IPv4Option.value's Router Alert decoding from the previous PR in this tier (same RFC, same field shape on the IPv6 side).
  • None — never raises — for every other routing type / option type, and for malformed data on the ones this library does decode (short buffer, address area not a whole number of 16-byte addresses). Same contract as every other .value/typed accessor across this tier.
  • Full test coverage: RH0 and Mobile IPv6 happy paths, zero-segment RH0, RPL explicitly confirmed as None, malformed address-area length, unknown routing type, Router Alert/Jumbo Payload happy paths and malformed-length cases, direct construction.

No breaking change: both are new properties; every existing field and accessor is unchanged.

Verification

  • uv run --frozen ruff check . and uv run --frozen ruff format --check . are clean
  • uv run --frozen mypy is clean (strict, src/ only)
  • uv run --frozen pytest passes locally (full suite)
  • uv run --frozen python scripts/benchmark.py --check --threshold 15 — 126,147 f/s, +14.6% vs. baseline, within threshold
  • CHANGELOG.md has an entry under ## [Unreleased]

New protocol or dispatch change — also:

Not applicable — no new protocol, no dispatch change. Deleted this block's checklist since it doesn't apply.

Notes

This is the fourth and last of #96's four independent PRs. Once this merges, #96 itself will be closed with a summary comment listing all four.

Part of #96.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CP7X7H4k3pBWoiAkBdxATM


Generated by Claude Code

IPv6Routing.data was entirely unparsed -- no segment-list extraction
for any routing type. RH0 and Mobile IPv6 both store a 4-byte reserved
field followed by one address per segment, which segments decodes
into a tuple[IPv6Address, ...].

RPL (routing_type 3) is deliberately not decoded. RFC 6554 elides a
shared prefix from each intermediate address relative to the enclosing
packet's destination address -- context a single extension header does
not carry on its own, the same class of problem DNS compression posed
for RDATA in an earlier PR of this tier, except here there's no
message-wide buffer to fall back on: IPv6Routing only ever sees its
own bytes. Attempting a partial or wrong decode would be worse than
leaving it raw, so data stays the only way to read an RPL header, same
as before this change.

IPv6Option.value decodes Router Alert and Jumbo Payload, mirroring the
IPv4 side of the same two RFCs (2711, 2675) landed two PRs ago in this
tier. This is the fourth and last of #96's four independent pieces.

Part of #96.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CP7X7H4k3pBWoiAkBdxATM
@EONRaider
EONRaider merged commit 5a72074 into master Sep 4, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants