x/net/ipv4: missing a way to parse Linux packets on Darwin #43386
Comments
Could you show some code example? That will be very helpful. |
@denisvmedia The The raw socket data on Linux is in network byte order (big endian) while the macOS raw socket data is already in the host byte-order or You would likely need to deal with the byte-order before feeding the data to |
@mengzhuo here is a minimal example: https://play.golang.org/p/BIPim30eLCN The output on Darwin and Linux will be different: 60 on Linux and it's correct, while on Mac it's 15380, which is incorrect. That's because there is a hard-coded runtime.GOOS switch in |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What did you do?
I captured TCP/IPv4 packets on Linux, saved them to files to be used in unit tests. Then I tried running unit tests on macOS and they failed. This was because of a hard-coded OS detection in ipv4.Header.Parse.
What did you expect to see?
I would expect to have a way to specify packet OS when I want to parse the packet. This feature would make the code of the library cleaner and less platform dependent. Currently, even tests are not clean (by having switch/case) and depend on the OS they are being run on.
What did you see instead?
I'm not able to use ipv4.ParseHeader with pre-saved files on a different platform.
The text was updated successfully, but these errors were encountered: