Skip to content

Add RFC4443 ICMPv6 payload slice support#141

Merged
JulianSchmid merged 1 commit intoJulianSchmid:masterfrom
xyzzyz:feature/rfc-4443-payloads
Mar 10, 2026
Merged

Add RFC4443 ICMPv6 payload slice support#141
JulianSchmid merged 1 commit intoJulianSchmid:masterfrom
xyzzyz:feature/rfc-4443-payloads

Conversation

@xyzzyz
Copy link
Contributor

@xyzzyz xyzzyz commented Mar 8, 2026

Extend ICMPv6 payload decoding with dedicated slice types for RFC4443 message bodies: Destination Unreachable, Packet Too Big, Time Exceeded, Parameter Problem, Echo Request, and Echo Reply.

Wire the new slice variants into Icmpv6PayloadSlice::from_slice and from_type_u8, including per-type code validation so unsupported type/code combinations still fall back to Raw. Keep owned Icmpv6Payload unchanged, as the new payloads don't have fixed data; to_payload continues to return None for the new variable-length RFC4443 slices.

For the invoking-packet message types, add as_lax_ip_slice helpers that parse the embedded packet via LaxIpSlice.

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced structured payload handlers for ICMPv6 message types: Destination Unreachable, Packet Too Big, Time Exceeded, Parameter Problem, Echo Request, and Echo Reply. Enables direct payload access and parsing of embedded IP packets with proper error handling.
  • Style

    • Code cleanup including minor formatting adjustments and removal of unused imports.

Extend ICMPv6 payload decoding with dedicated slice types for RFC4443 message bodies: Destination Unreachable, Packet Too Big, Time Exceeded, Parameter Problem, Echo Request, and Echo Reply. These slices model the variable-length payload bytes after the fixed 8-byte ICMPv6 header in the same style as existing ND payload slices, and include RFC layout docs plus focused accessors (invoking-packet/data views).

Wire the new slice variants into Icmpv6PayloadSlice::from_slice and from_type_u8, including per-type code validation so unsupported type/code combinations still fall back to Raw. Keep owned Icmpv6Payload unchanged for now; to_payload continues to return None for the new variable-length RFC4443 slices. For the invoking-packet message types, add as_lax_ip_slice helpers that parse the embedded packet via LaxIpSlice. Update ICMPv6 payload-slice and ICMPv6-slice tests to cover the new variants and decoding behavior.
@coderabbitai
Copy link

coderabbitai bot commented Mar 8, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: cfbb81bd-217a-4264-b383-52c51d4cb844

📥 Commits

Reviewing files that changed from the base of the PR and between d6d0f63 and 46dda0b.

📒 Files selected for processing (9)
  • etherparse/src/transport/icmpv6/icmpv6_payload/mod.rs
  • etherparse/src/transport/icmpv6/icmpv6_payload_slice/destination_unreachable_payload_slice.rs
  • etherparse/src/transport/icmpv6/icmpv6_payload_slice/echo_reply_payload_slice.rs
  • etherparse/src/transport/icmpv6/icmpv6_payload_slice/echo_request_payload_slice.rs
  • etherparse/src/transport/icmpv6/icmpv6_payload_slice/mod.rs
  • etherparse/src/transport/icmpv6/icmpv6_payload_slice/packet_too_big_payload_slice.rs
  • etherparse/src/transport/icmpv6/icmpv6_payload_slice/parameter_problem_payload_slice.rs
  • etherparse/src/transport/icmpv6/icmpv6_payload_slice/time_exceeded_payload_slice.rs
  • etherparse/src/transport/icmpv6_slice.rs

📝 Walkthrough

Walkthrough

This PR introduces new payload slice wrapper types for ICMPv6 error and echo messages (Destination Unreachable, Packet Too Big, Time Exceeded, Parameter Problem, Echo Request, Echo Reply), expands the Icmpv6PayloadSlice enum with corresponding variants, and refactors the payload parsing dispatch logic to route to the appropriate slice type constructors.

Changes

Cohort / File(s) Summary
Core ICMPv6 Payload Routing
icmpv6_payload_slice/mod.rs
Added six new variants to Icmpv6PayloadSlice enum. Reworked from_type_u8 to conditionally dispatch based on code/type mappings; updated from_slice, slice, and to_payload methods to handle new variants. Added comprehensive tests for all new payload types.
ICMPv6 Payload Slice Types (Error Messages)
icmpv6_payload_slice/destination_unreachable_payload_slice.rs, packet_too_big_payload_slice.rs, time_exceeded_payload_slice.rs, parameter_problem_payload_slice.rs
Introduced four new wrapper types for error message payloads. Each provides from_slice constructor, slice/invoking_packet accessors, and as_lax_ip_slice method for decoding embedded IP packets via LaxIpSlice integration.
ICMPv6 Payload Slice Types (Echo Messages)
icmpv6_payload_slice/echo_request_payload_slice.rs, echo_reply_payload_slice.rs
Introduced two new wrapper types for echo message payloads. Each provides from_slice constructor and slice/data accessors; no IP decoding required for these message types.
Minor Formatting & Cleanup
icmpv6_payload/mod.rs
Minor formatting adjustments to Icmpv6Payload::write method signature; removed unused alloc::format import from tests module.
Test Updates
icmpv6_slice.rs
Updated assertions to verify Echo Request/Reply payloads are wrapped in EchoRequestPayloadSlice/EchoReplyPayloadSlice variants instead of Raw.

Sequence Diagram(s)

sequenceDiagram
    participant Client as ICMPv6Parser
    participant Router as from_type_u8<br/>(routing logic)
    participant DestUnreach as DestinationUnreachable<br/>PayloadSlice
    participant EchoReq as EchoRequest<br/>PayloadSlice
    participant LaxIP as LaxIpSlice<br/>(IP decoding)

    Client->>Router: from_type_u8(icmp_type, code, payload_bytes)
    
    alt DestinationUnreachable code valid
        Router->>DestUnreach: from_slice(payload_bytes)
        DestUnreach-->>Router: DestinationUnreachable(wrapper)
        Router-->>Client: Icmpv6PayloadSlice::DestinationUnreachable
        Note over Client,LaxIP: Optional IP packet<br/>inspection available
    else PacketTooBig or TimeExceeded code valid
        Router->>DestUnreach: from_slice(payload_bytes)
        DestUnreach-->>Router: variant(wrapper)
        Router-->>Client: Icmpv6PayloadSlice variant
    else EchoRequest/Reply
        Router->>EchoReq: from_slice(payload_bytes)
        EchoReq-->>Router: wrapper
        Router-->>Client: Icmpv6PayloadSlice::EchoRequest/Reply
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Suggested reviewers

  • JulianSchmid

Poem

🐰 Six payload types now dance with glee,
Echo requests bounce wild and free,
Destination paths find their way through,
Error messages parsed—both old and new!
hops away into the networking blue 🌐

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely summarizes the main change: adding RFC4443 ICMPv6 payload slice support, which is the primary objective of the pull request.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

@JulianSchmid JulianSchmid merged commit f87e170 into JulianSchmid:master Mar 10, 2026
11 checks passed
@codecov
Copy link

codecov bot commented Mar 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (d6d0f63) to head (46dda0b).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@      Coverage Diff      @@
##   master   #141   +/-   ##
=============================
=============================

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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