Skip to content

ipv4: add Header.ParseWire and Header.MarshalWire - #271

Open
denisvmedia wants to merge 1 commit into
golang:masterfrom
denisvmedia:ipv4-parse-wire
Open

denisvmedia wants to merge 1 commit into
golang:masterfrom
denisvmedia:ipv4-parse-wire

Conversation

@denisvmedia

Copy link
Copy Markdown

Header.Parse and Header.Marshal use the format of a raw IP socket on
the local system. On Darwin, iOS, DragonFly BSD, NetBSD and older
FreeBSD the TotalLen and FragOff fields are in host byte order there,
and TotalLen may exclude the header length. A header captured on Linux,
which is in the wire format, is therefore parsed incorrectly on those
systems, and there is no way to parse it portably.

Add ParseWire and MarshalWire, which always use the wire format defined
in RFC 791. Describe the per-system differences with an internal
rawFormat type so that Parse/Marshal and the new methods share one
implementation. The behavior of Parse, Marshal and ParseHeader does not
change.

Fixes golang/go#43386

Header.Parse and Header.Marshal use the format of a raw IP socket on
the local system. On Darwin, iOS, DragonFly BSD, NetBSD and older
FreeBSD the TotalLen and FragOff fields are in host byte order there,
and TotalLen may exclude the header length. A header captured on Linux,
which is in the wire format, is therefore parsed incorrectly on those
systems, and there is no way to parse it portably.

Add ParseWire and MarshalWire, which always use the wire format defined
in RFC 791. Describe the per-system differences with an internal
rawFormat type so that Parse/Marshal and the new methods share one
implementation. The behavior of Parse, Marshal and ParseHeader does not
change.

Fixes golang/go#43386
@google-cla

google-cla Bot commented Oct 8, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@denisvmedia denisvmedia closed this Oct 8, 2026
@denisvmedia

denisvmedia commented Oct 8, 2026 •

Copy link
Copy Markdown
Author

(don't won't to include my email in a publicly visible commit for CLA, but anyone can use this code freely)

@denisvmedia denisvmedia reopened this Oct 8, 2026
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.

x/net/ipv4: missing a way to parse Linux packets on Darwin

1 participant