Skip to content

wrong tot_len field of serialized ip package #550

Description

@Streamlet

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions