Skip to content

Conversation

sat0ken
Copy link
Contributor

@sat0ken sat0ken commented Jan 30, 2025

Add implementation SerializeTo to IPv6Routing

#106

Signed-off-by: sat0ken <15720506+sat0ken@users.noreply.github.com>
Signed-off-by: sat0ken <15720506+sat0ken@users.noreply.github.com>
…ken/gopacket into feature/add-SerializeTo-IPv6Routing
@sat0ken sat0ken changed the title Feature/add serialize to i pv6 routing Feature/add serialize to ipv6 routing Jan 30, 2025
@mosajjal mosajjal self-assigned this May 30, 2025
@mosajjal mosajjal requested a review from Copilot May 30, 2025 20:16
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds a SerializeTo method to the IPv6Routing layer so it can implement gopacket.SerializableLayer and be serialized back into bytes.

  • Compute total header length (base + routing addresses) and header extension length
  • Prepend bytes and fill in NextHeader, HdrExtLen, RoutingType, SegmentsLeft, Reserved, and address list
  • Copy each routing IP into the payload area
Comments suppressed due to low confidence (2)

layers/ip6.go:580

  • [nitpick] The loop variable i shadows the receiver i. Rename the index variable (e.g., to idx) to avoid confusion.
for i, ip := range i.SourceRoutingIPs {

layers/ip6.go:567

  • There are no unit tests covering SerializeTo. Consider adding tests for both empty and non-empty SourceRoutingIPs to verify correct serialization.
func (i *IPv6Routing) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error {

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@mosajjal mosajjal merged commit 2e40d04 into gopacket:master Aug 1, 2025
1 check 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