IPv6: decode Routing header segments and Router Alert/Jumbo Payload - #139
Merged
Conversation
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
This was referenced Sep 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.datais entirely unparsed — no segment-list extraction for RH0, RPL or Mobile IPv6.IPv6Optionlikewise decodes no values (Router Alert, Jumbo Payload stay raw).What's included
IPv6Routing.segments— a new property. RH0 (routing_type0, deprecated by RFC 5095 but still seen — RFC 2460 §4.4) and Mobile IPv6 (routing_type2, RFC 6275 §6.4) both store a 4-byte reserved field followed by one IPv6 address per segment; decodes totuple[ipaddress.IPv6Address, ...].routing_type3) 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 (IPv6Routingonly ever sees its own bytes, unlikeDNSResourceRecord.rdata_value, which could reach back intoDNS.sections). Attempting a partial or wrong decode would be worse than leaving it raw —datastays 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 typedints, mirroringIPv4Option.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.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 .anduv run --frozen ruff format --check .are cleanuv run --frozen mypyis clean (strict,src/only)uv run --frozen pytestpasses locally (full suite)uv run --frozen python scripts/benchmark.py --check --threshold 15— 126,147 f/s, +14.6% vs. baseline, within thresholdCHANGELOG.mdhas 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