I noticed the following code in ip.cpp
#if __FreeBSD__ || defined(__FreeBSD_kernel__) || __APPLE__
if (!parent_pdu()) {
total_sz = Endian::host_to_be<uint16_t>(total_sz);
header_.frag_off = Endian::be_to_host(header_.frag_off);
}
#endif
This conditionally reverses byte order on BSD and macOS.
However, BSD and macOS machines are usually little-endian, so the issue here is not endianness.
The actual difference comes from how the IP header bitfields are defined on BSD/macOS versus Linux. It seems the code is conflating bitfield layout differences with byte order differences.
I noticed the following code in
ip.cppThis conditionally reverses byte order on BSD and macOS.
However, BSD and macOS machines are usually little-endian, so the issue here is not endianness.
The actual difference comes from how the IP header bitfields are defined on BSD/macOS versus Linux. It seems the code is conflating bitfield layout differences with byte order differences.