Skip to content

Conversation

mejedi
Copy link
Contributor

@mejedi mejedi commented Jan 27, 2025

The prior implementation of Htons attempted big endian detection via comparison of binary.NativeEndian.String() with binary.BigEndian.String(). It turns out that the former always returns "NativeEndian", hence it didn't work as intended.

Rewrite endian detection by passing []byte{0x12, 0x34} through Endian.Uint16(). Add test to ensure that detection works both on little and big endian CPUs.

The prior implementation of Htons attempted big endian detection via
comparison of binary.NativeEndian.String() with binary.BigEndian.String().
It turns out that the former always returns "NativeEndian", hence it
didn't work as intended.

Rewrite endian detection by passing []byte{0x12, 0x34} through
Endian.Uint16(). Add test to ensure that detection works both on little
and big endian CPUs.
@mejedi
Copy link
Contributor Author

mejedi commented Jan 27, 2025

@mosajjal sorry for messing it up on the first try

@mosajjal mosajjal merged commit 9c54b11 into gopacket:master Feb 6, 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